SSMTP
From ArchWiki
SSMTP is a program to deliver an email from a local computer to a configured mailhost (mailhub). It is not a mail server (like feature-rich mail server sendmail) and does not receive mail, expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an to an external email address.
Contents |
Installation
To install SSMTP:
pacman -S ssmtp
Forward to a Gmail Mail Server
To configure SSMTP, you will have to edit its configuration file (/etc/ssmtp/ssmtp.conf) and enter your account settings:
# The user that gets all the mails (UID < 1000, usually the admin) root=username@gmail.com # The mail server (where the mail is sent to). mailhub=smtp.gmail.com:465 # The address where the mail appears to come from for user authentification. rewriteDomain=gmail.com # The full hostname hostname=localhost # Use SSL/TLS before starting negotiation UseTLS=YES # Username/Password AuthUser=username AuthPass=password # Email 'From header's can override the default domain? FromLineOverride=yes
Change the file permissions of /etc/ssmtp/ssmtp.conf because the password is printed in plain text (so that other users on your system cannot see your Gmail password):
chmod 600 /etc/ssmtp/ssmtp.conf
In /etc/ssmtp/revaliases you will need to define your aliases:
root:username@gmail.com:smtp.gmail.com:465 mainuser:username@gmail.com:smtp.gmail.com:465
To test whether the Gmail server will properly forward your email:
echo test | mail -s "testing ssmtp setup" username@somedomain.com
'username@somedomain.com' can be any valid email address you have access to to test. Gmail's smtp server will forward to your own Gmail account too if you would like to use that.
As an alternate method for sending emails, even using a Gmail alias, you can create a text file:
To:username@somedomain.com From:youraccount@gmail.com Subject: Test This is a test mail.
Save the file and send it through ssmtp:
ssmtp youraccount@gmail.com < test
Attachments
This method does not work with attachments. If you need to be able to add attachments, install and configure Mutt and Msmtp and then go see the tip at nixcraft.