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);