Google is deprecating, and will soon turn off, Gmail’s ability to fetch mail from other servers via POP. (Despite what you may have thought, Gmail has apparently never supported fetching over IMAP.) In an update, covered in the link above, Google has extended this deprecation to it’s send-as feature as well. So while this tool will still work, it won’t be possible to use your Gmail account as your primary interface to reading and responding to email at another domain. Forwarding by SMTP is not a good substitute: forwarded messages commonly fail SPF, DKIM, and DMARC checks, because the forwarding server is no longer an authorized sender for the original domain. (The ARC protocol exists to soften this, but it depends on the receiving side trusting you.) So I turned to Gmail’s API, and after a little more research than I wanted, I wrote a modest Python script.

In an updatex Google has extended this enshittification to it’s send-as feature as well. So while this tool will still work, it won’t be possible to use your Gmail account as your primary interface to reading and responding to email at another domain.

gmailSender

gmailSender reads email on standard input, either as a single message or in mbox format, and inserts it into a Gmail account using the Gmail API. This is mailbox delivery, not a way to send mail to arbitrary recipients. The destination account must grant OAuth access. A server for my own domain can receive a message and pass it to the script, which imports it into an Oauth authorized Gmail mailbox.

Later this year Google will likely also disable sending mail through a remote server (“send mail as”). Once that happens you will no longer be able to reply from Gmail as an address hosted elsewhere. This is yet another example of enshittification, which seems to be “the way of things” at Google. I wrote more about that in Gmail Enshittification.

Credits

  • While searching for a way to get mail into Google, I found Jeremy Ephron’s simplegmail repository, which gave me some insight into the Gmail API and was the genesis of this idea.
  • Anthropic’s Claude produced two proof-of-concept attempts that were close to working and taught me more about the Gmail API, but were broken in various ways. Claude also helped move the code to Python’s more modern EmailMessage class, which fixed several bugs in the earlier versions.
  • Claude also tried to build a version that accepted both single messages and multi-message mboxes on standard input. It did so with Python 2’s PortableUnixMailbox, but Python 3’s mailbox.mbox takes a path, not a file-like object. Enrico Zini has a way around that in Python hacks: opening a compressed mailbox. In the end, reading raw bytes and parsing them with EmailMessage and email.policy.default turned out to be much more straightforward and less fragile.