MyDaftQuestions
MyDaftQuestions

Reputation: 4701

Sending an email from Gmail Alias in a Google Workspace

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("[email protected]", GetPassword()),
    EnableSsl = true
};
          
var message = new MailMessage();
message.From = new MailAddress("[email protected]", "Support"); 
message.To.Add("[email protected]");
message.Subject = "test";
client.Send(message);

The problem I have is when the code executes, the email is always sent from [email protected]

What do I need to do to ensure the email is sent from [email protected]

Upvotes: 2

Views: 1420

Answers (1)

MyDaftQuestions
MyDaftQuestions

Reputation: 4701

The code was fine

Despite having set up the alias in admin.google.com, I had to log into Gmail, click the cog, then more settings.

From here, click the accounts tab, and under the Send mail as, click on Add another email address, creating another alias. Not sure why I have options to do this in 2 places

Upvotes: 4

Related Questions