I have a MailMessage that I'm sending with the following:
email.To.Add(new MailAddress(receiver.Email, receiver.Username));
email.From = new MailAddress(sender.Email, "app (on behalf of " + sender.Username + ")");
email.Sender = new MailAddress("app@gmail.com", "App");
The idea is that the email will be sent to the receiver with the sender's email address in the FROM header, so that the receiver can hit "Reply" in their email client, and email the sender directly.
Currently, when I get an email as Receiver, I hit reply to and get app@gmail.com, while the FROM text says (on behalf of), as it should.
Is this not the proper way to set the message up?
In case it matters, my smtpClient:
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("app@gmail.com", "Password"),
EnableSsl = true
};