I am struggling with sending an email from an alias account I have in a Google Workspace. This is so I can send emails from within my website using a generic email address (such as info@, or support@). This means the domain will remain the same, but the text before the @ will be different.
I have created the alias, and from my reading, I can send emails from an alias but I need to use my real account to authenticate. I have also created the App Password and emails send, just not from the alias.
The code I am using is
var client = new SmtpClient(_host, 587)
{
Credentials = new NetworkCredential("myRealUsername@domain.com", GetPassword()),
EnableSsl = true
};
var message = new MailMessage();
message.From = new MailAddress("myAlias@domain.com", "Support");
message.To.Add("anotherAccount@domain.com");
message.Subject = "test";
client.Send(message);
The problem I have is when the code executes, the email is always sent from myRealUsername@domain.com
What do I need to do to ensure the email is sent from myAlias@domain.com