Take the 2-minute tour ×

I need to implement a “email support” section in our application. So email “To” address will be admin@mydomain.com” 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 user@mydomain.com or user@gmail.com).

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

System.Net.NetworkCredential("admin@mydomain.com", 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.From = new MailAddress(“test@gmail.com”);
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
var smtp = new SmtpClient("mail.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredential(admin@mydomain.com, adminpassword);
smtp.EnableSsl = false;
object usrtkn = message;
share|improve this question
add comment

2 Answers

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.

share|improve this answer
Glad to see you have the same interpretation of the roles the user and system should be playing in this scenario. :-) –  Karl Anderson Jul 18 '13 at 13:10
@KarlAnderson: Agreed. I often see people trying to remove the software from the audit trail and make it look like the user is directly doing everything, but that's just not the case. (publicvoidlife.blogspot.com/2012/05/…) The application is itself a user of the back-end services and should be treated as such. –  David Jul 18 '13 at 13:17
add comment

You cannot do what you are doing, because the SMTP server is not allowing you to "impersonate" the user's email address for sending to the system. And thank goodness this is the case or else people would be spamming/spoofing the heck out of everyone under someone else's name.

Why are you trying to have it appear that the user is sending an email to the application? Why not just have a support section of your application where users can "submit" requests for support to the system and then if you want to send emails out to the users, then your scenario will work, but just in reverse (where the system is the From address and the user is the To address).

share|improve this answer
add comment

Your Answer


