Skip to content

Yet another way to configuring Linux to send emails using mailutils and postfix.

Notifications You must be signed in to change notification settings

vanderblugen/Send-Emails-from-Linux-with-Postfix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 

Repository files navigation

Send Emails from Linux with Postfix

This is for configuring Linux to be able to send emails.

This information was obtained from here for my enjoyment and so I don't have to look for this again. . This has been tested on a Raspbery pi and an Ubuntu machine.

This configuration uses Gmail as the email carrier. It will work with others, just used gmail in this configuration. Less secure apps or 2 factor with app passwords needs to be enabled for this configuration to work.

Install needed apps

sudo apt-get install postfix libsasl2-modules mailutils -y

Select internet site on installation

Add email password

sudo nano -B /etc/postfix/sasl/sasl_passwd

Add smtp.gmail.com:587 username@gmail.com:password with the appropriate information

Crtl+X' and Enter` to save and exit

Update the password file

sudo chmod u=rw,go= /etc/postfix/sasl/sasl_passwd
sudo postmap /etc/postfix/sasl/sasl_passwd

Edit postfix configuration file

sudo cp /etc/postfix/main.cf !#$.dist
sudo nano /etc/postfix/main.cf

Change relayhost = to relayhost = smtp.gmail.com:587

Change smtp_tls_security_level=may to #smtp_tls_security_level=may

Add this at the bottom

# Enable authentication using SASL.
smtp_sasl_auth_enable = yes
# Use transport layer security (TLS) encryption.
smtp_tls_security_level = encrypt
# Do not allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# Specify where to find the login information.
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Where to find the certificate authority (CA) certificates.
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

Exit and Save with Ctrl+X and Enter

Restart Postfix

sudo service postfix restart

Send a test email

echo "Subject: Test Email Subject" | mail -a test_email@address.com < echo "Here is a test email"

About

Yet another way to configuring Linux to send emails using mailutils and postfix.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages