Often when installing a web application or script you need an SMTP server to send email but rarely there is the need to recieve any email and on those occasions it is unnecessary to set up an full blown SMTP server like Postfix, Sendmail or Exim. It works equally well using ssmtp, which also is simple and fast to install. It takes two minutes to install and configure.
Start the installation with apt-get:
1 |
apt-get install ssmtp |
The configuration is done in the /etc/ssmtp/ssmtp.conf and there is not much needing to be configured:
Mailhub
The mail server you must send mail through (relay). In this guide we will use GMail smtp Server.
From Line Override
Set to YES to allow the use of others choose from addresses other than the system itself.
AuthUser
The username or email adress on the account used to login to gmail.
AuthPass
The password for above account
UseSTARTTLS
Set to Yes to use TLS when connecting to the SMTP server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. root=postmaster # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=smtp.gmail.com:587 AuthUser=name@gmail.com AuthPass=YourtopSecretPassw0rd! UseSTARTTLS=YES # Where will the mail seem to come from? #rewriteDomain= # The full hostname hostname=debianVPS.local # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES |
No reboots required. Ssmtp create / usr / sbin / sendmail, such as PHP uses to send mail. You have no open ports, everything just works.
really good, when running wordpress, we may need to send some comment reply notification mail or database backup mail, so I think this is OK and enough for such implenmentation?
not work! always got err:send-mail: Authorization failed (534 5.7.14 54 tr10sm768553pbc.22 – gsmtp)
changed the mail password once ,then it works fine
There you go!
Glad that it is to good use.
ssmtp is too restrictive and can only send through a single smtp server.
smtp-cli is much more powerful.
http://www.logix.cz/michal/devel/smtp-cli/
Sometimes you only need one SMTP server, as an example if you are forced to use a smarthost.
at my regular job we block port 25 from our customers servers and force them to use the mailrelay that we have setup instead.
I’m not bashing your suggestion, it’s just another way of doing it 🙂 Thank you for sharing your knowledge.