SMTP Mail Send, show actual email address instead of from email address.

0 votes
asked May 8, 2019 by maulik.simfrom.p (120 points)
edited May 8, 2019 by maulik.simfrom.p


I am trying to send email using rcpt to. I had set from address( but at the receiver and it show actual email address ( Can you please help me to solve this problem? Here is my code.

Smtp smtp = new Smtp();
smtp.Connect("", SslMode.Explicit);
smtp.Login("", password, SmtpAuthentication.Login);                

string mailFrom = "";
string rcptTo = "";
string mailTo = "";

MailMessage mail = new MailMessage();
mail.To = mailTo;
mail.From = mailFrom;
mail.Headers.Add("From", mailFrom);
mail.Subject = "Hello Freddy, this is your friend Peter sending you a test email";
mail.BodyText = "Hello Freddy, this is the body text";

smtp.Send(mail, mailFrom, rcptTo);

I tried with sample that I got from the website. But I still got same error. It behave same for both Send method.

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered May 9, 2019 by Lukas Matyska (61,230 points)

This seems to be a specific of Gmail SMTP server.

I have 3 hints:

  1. Do not call mail.Headers.Add("From", mailFrom); by calling this, you added another From header to the message. Maybe, this can cause troubles with GMail.

  2. Try to set mail.Sender as well. It can be done like this:

    MailMessage mail = new MailMessage();
    mail.From = mailFrom;
    mail.Sender = mailFrom;

  3. Try to look into Gmail settings. I think that the accounts of the two users "auth" and "from" should be linked somehow. And the "auth" user should have permission to send mails on behalf of "from" user.

commented May 9, 2019 by maulik.simfrom.p (120 points)
Thanks Lukas
I have tried with mail.Sender property. But I got same result.
I have removed header as  you suggest me. The emails are not linked. I have permission to send mail. I can get desire result with System.Net.Mail.Smtp.
commented May 9, 2019 by Lukas Matyska (61,230 points)
Can you please share with us the code you used for System.Net.Mail.Smtp?
You can send it to
If system Smtp class is able to make this working, we should be able to do it as well.