How can I modify the sender's email when using Gmail SMTP in C#?

Emails sent with Gmail SMTP in C# display the original Gmail sender despite setting a different From address. E.g.:

var email = new System.Net.Mail.MailMessage(){ From = new System.Net.Mail.MailAddress("[email protected]") };

hey, i noticed that with gmail you cant fully mask your sender info so it always shows your google account too. you may need a different smtp server if you really need that custom sender, its a gmail limitation

Based on my experience, Gmail indeed limits the ability to customize the sender email. I remember spending quite a bit of time trying to set up a custom sender in a project, only to eventually discover that Gmail’s SMTP service verifies and highlights the primary account email. This behavior enforces a security protocol intended to reduce spoofing. When complete customization is required, opting for a dedicated SMTP server or using services that allow more sender flexibility turned out to be a better long-term solution for me.

I encountered a similar issue while sending emails using Gmail SMTP in a C# project. Gmail tends to enforce its policy where the primary account email is prominently featured, regardless of any custom From address set in the code. In my experience, ensuring that additional sender emails are properly verified in your Gmail settings might help, though it rarely gives complete control over the displayed sender information. For full customization, using an alternative SMTP server that allows more flexibility or setting up your own email service may be the more effective solution.