7

I'm sending email via the Gmail API, in Python, as per https://developers.google.com/gmail/api/v1/reference/users/messages/send#examples

I have a domain alias and inboxes setup with catch-all addresses, so emails to anything@sub.example.com and anything@alias.example.com both end up in the inbox for tech@sub.example.com.

Both tech@sub.example.com and tech@alias.example.com are set as "accounts I own" in the Gmail settings, and I did not have to verify ownership of the second account when I added it (presumably because its domain is an alias).

Using the API I'm processing received emails and then re-sending them from the account they were sent to, setting the "from" header in the MIMEMessage. Unfortunately they're always received as sent from the email address owning the mailbox.

Other questions (e.g. [1], [2]) suggest this should "just work", at least via SMTP, which I've also tried. I think it must be a quirk of using a domain alias.

[1] Changing the `from` address when sending an email through GMail

[2] How to set From Address to any email other gmail in ( Sending Email in .NET Through Gmail )?

αғsнιη
  • 2,627
  • 2
  • 25
  • 38
Matt
  • 2,153
  • 1
  • 18
  • 29
  • I think you have to add these aliases to the configuration in your email account. Here is the documentation on how to add the aliases as options to "send email as". After configuring this, if the value in the "From" is a valid alias, it will be sent from that addess, otherwise it will use the addess of your current account. https://support.google.com/mail/answer/22370?hl=en – Gerardo Sep 16 '15 at 21:30
  • I have done exactly that. Contrary to those instructions though, there is no "Send Verification" step. The "send mail as" account just gets added. Sending an email through the interface I can choose between the two accounts no problem, but when I use the API it always comes from the primary account, regardless of what I put in the "From" header – Matt Sep 20 '15 at 18:14
  • I was able to do it with the python example you mentioned as well within the documentation. The only think i can guess is that the aliases were configured in a different account. could you verify that? it may happen when you are logged with different accounts at the same time. https://developers.google.com/gmail/api/v1/reference/users/messages/send – Gerardo Sep 21 '15 at 23:20

0 Answers0