• Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy
Cybersylum

Cybersylum

  • Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy

SMTP Forwarding in a Home Lab

byArron King 06.26.2023 Home Lab Linux

I use a small Linux VM in my environment to relay outbound SMTP using my e-mail provider. This is primarily used to get alerts and notifications from my Home Lab systems to my inbox.

My Ubuntu version was at end-of-life so it was time to rebuild with the latest version.  I thought this was a good time to publish my notes to help myself – and anyone else!

Acknowledgements

I relied on 3 different blog articles to get this setup.  I am sure there are other ways to accomplish this task; but these worked for me:

  • https://www.linode.com/docs/guides/configure-postfix-to-send-mail-using-gmail-and-google-workspace-on-debian-or-ubuntu/
  • https://www.linuxsysadmins.com/forcing-the-from-address-when-postfix-relays-over-smtp
  • Setup App-specific passwords for Apple IDs

Goals

  • SMTP host capable of relaying emails from internal systems to my e-mail provider.
    • No inbound SMTP is needed or desired
    • SMTP had to send email using specific username/credentials
  • Initially it had to work with Gmail.  I had the legacy free version of Google Apps since 2010.  When that was initially announced to be shuttered, I moved all of my email services to Apple.  Shortly after I had moved everything.  Google announced it had changed its mind and was not shutting down Legacy G Suite after all; but that was too late for me.  The steps below work for both Gmail and Apple mail.

Setting up the Relay

My new Linux VM is running Ubuntu 22.04.2 LTS.   You may need to make some adjustments in the steps below to account for your distro of choice.

Install Postfix and LIBSASL2

This is from Linode article above

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postfix libsasl2-modules

You will be prompted to make a configuration choice on Postfix.  Choose Internet site and enter your system mail name.

Edit Postfix config file (/etc/postfix/main.cf)

Locate the myhostname parameter and ensure it matches your server’s FQDN

myhostname = host.cybersylum.com

At the end of the main.cf file add the following lines:

note: your postfix config file may have existing entries for these configuration items.  You can remove them.  I keep my updates in a group to make it easier to find

# use Apple SMTP relay
relayhost = [smtp.mail.me.com]:587
#allow relay from specific local VLANs
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.4.0/24 192.168.9.0/24
#force email to go out as my personal email
sender_canonical_classes = envelope_sender,header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps
header_checks = regexp:/etc/postfix/header_checks

Create sender_canonical_maps file (/etc/postfix/sender_canonical_maps) – from the LinuxSysAdmins article

/.+/ [email protected]

Create header_checks file (/etc/postfix/header_checks) – from the LinuxSysAdmins article

/From:.*/ REPLACE From:[email protected]

Create sassl_password file (/etc/postfix/sasl/sasl_password)

[smtp.mail.me.com]:587 [email protected]:password

Create the hash db file 

sudo postmap /etc/postfix/sasl/sasl_passwd

Secure the DB hash and password files

sudo chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db 
sudo chmod 0600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db

Restart Postfix

sudo systemctl restart postfix

Testing

You can use the sendmail command to test the config and review the logs at /var/log/syslog to look for errors.

 

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn

vToolbelt - June 2023

vToobelt - July 2023

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Disclaimer

The content and opinions on this site belong to me - not my employer.

You are welcome to use any ideas or code from this site. You have the responsiblity to test these before using in a production environment.

Upcoming Events

  • Wed
    22
    Oct
    2025

    Cincinnati VMware VMUG UserCON

    Save The Date!

    The VMware VMUG UserCON returns to Cincinnati in October 2025

Categories

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10

Archives

Category

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10
Proudly powered by WordPress | Theme: Showme by NEThemes.