I am creating a System.Net.Mail.MailMessage and sending it using SmtpClient.
I send the email using [email protected], i.e. that is the Sender and From is set to [email protected].
The receiver of the email will then see "SenderEmail on behalf of FromEmail". Ideally I simply want the from display to say "FromEmail" so receiver cannot see it is sent using [email protected].
Is there any way to do that?
var sendOnBehalfOfEmail = "[email protected]";
var mail2 = new System.Net.Mail.MailMessage();
mail2.Sender = new MailAddress("[email protected]");
mail2.From = new MailAddress(sendOnBehalfOfEmail);
mail2.ReplyToList.Add(sendOnBehalfOfEmail);
mail2.To.Add(new MailAddress("[email protected]"));
mail2.Subject = "Subject Test";
mail2.Body = "Body Test";
var credentials = new NetworkCredential("FromEmail", password);
using (var smtp = new SmtpClient("smtp...", 587))
{
smtp.Credentials = credentials;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail2);
smtp.Dispose();
}