Email Support section with the users address as "From address"

I need to implement a “email support” section in our application. So email “To” address will be [email protected]” and from address will be the email address of the end user.(The end users email address may be on the same domain or another domain like [email protected] or [email protected]).

In the application I am authenticated the email using admins account details (username and password)

System.Net.NetworkCredential("[email protected]", adminpassword);

Also I am using host address as “mail.mydomain.com” Issue is I am getting the following error:

“Mailbox unavailable. The server response was: From address must match authenticated address” error message.

Is it possible to send an email with the correct sender email address(users from address)

My code sample is

message.To.Add(“[email protected]”);
message.From = new MailAddress(“[email protected]”);
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
var smtp = new SmtpClient("mail.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredential([email protected], adminpassword);
smtp.EnableSsl = false;
object usrtkn = message;
smtp.Send(message);

Solution 1:

In general the From address shouldn't be the user themselves, it should be an internal system address. This is mainly because the user isn't actually sending the email, the application is. In the email itself you can specify which user sent it (and what their email address is). You can perhaps even specify the user's email address in the ReplyTo field of the message.

But the message you're getting from the SMTP server pretty much says it all. If the message is "from" that user then the SMTP server refuses it because it's sensitive to authentication and origination of emails. To the SMTP server (to any SMTP server I would imagine) it looks like you're trying to spoof messages.