User Tools

Site Tools


networking:linux:ssmtp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
networking:linux:ssmtp [2016/10/08 10:10]
gcooper
networking:linux:ssmtp [2020/02/14 09:43] (current)
gcooper
Line 18: Line 18:
  
 ===== Installation ===== ===== Installation =====
 +
 +==== Ubuntu ====
 +
 +<file>
 +apt install ssmtp bsd-mailx
 +</file>
 +
 +==== CentOS ====
  
 See also **[[computing:linux:epel|Using the EPEL Repository]]** See also **[[computing:linux:epel|Using the EPEL Repository]]**
Line 31: Line 39:
 <file> <file>
 rpm -e --nodeps sendmail rpm -e --nodeps sendmail
 +</file>
 +
 +===== From Address =====
 +
 +<note important>In modern times, secure mail servers are very strict about who is authorized to send mail.  You generally must use a **valid sender e-mail 'from address'** that **matches the authentication credentials** used.</note>
 +
 +<note>Using ''FromLineOverride=YES'' will allow the sender to specify the 'from address' at the time of sending.  ''FromLineOverride=NO'' will force the 'from address' to the ''root=validsender@domain.tld'' line in ''ssmtp.conf''.</note> 
 +
 +For sending **system or 'root' mail**, you will probably have to manipulate the 'from address' to get SSMTP to send mail through a secure mail server.
 +
 +<file>
 +vi /etc/ssmtp/revaliases
 +
 +root:validsender@domain.tld
 </file> </file>
  
 ===== Configuration ===== ===== Configuration =====
 +
 +For **SSL** connections on **SMTPS port 465**:
  
 <file> <file>
-vim /etc/ssmtp/ssmtp.conf+vi /etc/ssmtp/ssmtp.conf
  
-root=adminuser@yourdomain.com +root=validsender@domain.tld      # will be the 'from address' 
-mailhub=mail.yourdomain.com:465 +mailhub=mail.domain.tld:465      # to use SSL on port 465 
-RewriteDomain=yourdomain.com+RewriteDomain=domain.tld         # instead of the host name
 #hostname=_HOSTNAME_ #hostname=_HOSTNAME_
-FromLineOverride=YES +#FromLineOverride=YES            # allows setting 'from address' at runtime 
-UseTLS=YES+UseTLS=YES                       # for SSL
 AuthUser=smtpuser AuthUser=smtpuser
 AuthPass=smtppass AuthPass=smtppass
 +#Debug=YES                       # useful for troubleshooting
 </file> </file>
  
-:!: If you need to use **port 587**, you will probably need to add ''UseSTARTTLS=YES''.+:!: If you want to use **TLS** connections on **Submission port 587**, you will need to add/change: 
 + 
 +<file> 
 +mailhub=mail.domain.tld:587 
 +#UseTLS=YES 
 +UseSTARTTLS=YES 
 +#TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt   # Depends on configuration - Not needed on Ubuntu 18.04 
 +</file>
  
 :!: If you don't specify a ''hostname'', SSMTP will query the local machine.  Since we are authenticating, the hostname doesn't matter too much. :!: If you don't specify a ''hostname'', SSMTP will query the local machine.  Since we are authenticating, the hostname doesn't matter too much.
  
 ===== Test ===== ===== Test =====
 +
 +:!: If desired, enable (un-comment) the **debug** line, then look in ''/var/log/maillog''.
  
 If desired, install the ''mail'' command: If desired, install the ''mail'' command:
Line 71: Line 105:
  
 <file> <file>
-echo test | ssmtp -v tester@yourdomain.com+echo test | ssmtp -v -f "from@domain.tld" -F "Full Name" tester@yourdomain.com
 </file> </file>
  
Line 86: Line 120:
 <file> <file>
 cat << EOF >> /tmp/test.eml cat << EOF >> /tmp/test.eml
-From: MyPBX <smtp@MyPBX+From: Full Name <validsender@domain.tld
-To: Test <tester@yourdomain.com>+To: Test User <tester@somedomain.tld>
 Subject: For test only! Subject: For test only!
  
Line 94: Line 128:
  
 ssmtp -t < /tmp/test.eml ssmtp -t < /tmp/test.eml
 +</file>
 +
 +===== Troubleshooting =====
 +
 +<file>
 +Debug=YES
 +</file>
 +
 +<file>
 +tail -30 /var/log/mail.log
 </file> </file>
  
networking/linux/ssmtp.1475943025.txt.gz · Last modified: 2016/10/08 10:10 by gcooper