+1 vote

Hello,

I bought Mail.dll in 2013, I have a problem:
I want to send email via smtp.gmail.com and user xxx@gmail.com, but I want the “mailbox from” to appear as xxx@mydomain.com

Here’s the example:

smtp.Connect(_server, Security.MAIL_SERVER_PORT);     

smtp.StartTLS();
smtp.Login("xxx@gmail.com", "gmailPass");

IMail email = Mail
    .Html(_message)
    .Subject(_subject)
    .From(new MailBox("emailOfMyDomain@mydomain.com", "myDomainEmail"))
    .To(new MailBox(_email, _email))              
    .Create();

smtp.SendMessage(email);

smtp.Close();

It don’t work, the sender is always x@gmail.com

by

1 Answer

0 votes
 
Best answer

Unfortunately, this is not possible for any email address. Gmail always overrides "From: " or "Sender: " email header to match the user that is logged-in to the SMTP server.

However Gmail lets you send messages with another of your email addresses listed as the sender instead of your Gmail address. It works only if you already own the email account linked to the alternate address.

To send mail from a different Gmail username, you'll first need to sign up for that address.

  • Click the Accounts and Import tab.
  • Under Send mail as, click Add another email address.
  • In the 'Email address' field, enter your name and alternate email address you own.

Now you can use Gmail's outbound servers with a different "from" address. If you've already configured the alternate address, your message will be sent "From: otheraddress@domain.com", "Sender: username@gmail.com", regardless of which custom from configuration you chose.

by (297k points)
...