I have domain.com
on GSuite. Then I have aliasdomain.com
(which is set as an alias domain for that in GSuite.) And I have a GSuite User admin
(which is both admin@domain.com
and admin@aliasdomain.com
just like I want them to be. Emails sent to either are received via gmail's admin@domain.com
account, all good.
Now I have an Ubuntu 18.04 Server from which I would like to send mail as admin@aliasdomain.com
. I have learned that I need to use Google SMTP to accomplish that.
I've also learned that nullmailer is light and since I only wish to send a mail very occasionally, it is perfect, so I'd like to use that preferably, but Postfix or sendmail can also be an option, if that doesn't work.
Unfortunately I have very limited understanding of anything related to mail transfer agents, etc. But I've tried my best to search for a resource or a guide for this particular scenario, but most of them are quite advanced to me, and they assume the reader to be very well-versed.
How do I set up sending mail using the above scenario? I am hoping someone kind enough to guide me in this regard.
Thank you very much.
OK, after some trial and error, I finally got it all working. Here's a step-by-step tutorial (sort of) if anyone is interested:
admin@domain.com
's gmail and enable Send mail as (refer to its section of Step 3 here, under Send messages from your alias addressdomain.com
's Google Admin Console > Apps > sudo apt-get install nullmailer
(then accept all default values for now, we're changing them below)cd /etc/nullmailer
sudo nano defaultdomain
and replace all text with aliasdomain.com
sudo nano adminaddr
and replace all text with admin@aliasdomain.com
sudo nano remotes
and replace all text with smtp.gmail.com smtp --port=465 --auth-login --user=admin@domain.com --pass=YOURPASSWORDFORadmin@domain.comGMAILACCOUNT --ssl
(Read important security note below before doing this step!)sudo systemctl enable nullmailer
sudo systemctl start nullmailer
printf "Subject: Nullmailer test\nFrom:admin@aliasdomain.com\nTo:example@hotmail.com\n\nTest from Nullmailer" | sendmail -v example@hotmail.com
Before attempting Step 2.5, You must either enable two-factor authorization for admin@domain.com
and use App Passwords OR enable Less secure apps. It's your decision ultimately.
You may have to include domain.com
and aliasdomain.com
in the an SPF TXT RECORD to.