I was trying to send from a aspx page a mail message using the smtp gmail (we are google apps customers and I tried with a paid account and with a free gmail...) I was able to send the messagge setting credentials, port, ssl, etc. but what is wrong is the From address of the message. Indeed, the mail is coming always from the address of the auth user and not from what I set in the msg.From property...
Eg. the mail arrives with from "[email protected]" and not from [email protected]
MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]", "sender name");
msg.To.Add(new MailAddress("[email protected]","recipient name"));
msg.Subject = "subject";
msg.Body = "some body";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "*******");
smtp.EnableSsl = true;
smtp.Send(msg);
Is there a setting to avoid this ?
thanks in advance
Sandro