Författare:
Per Stenebo
Skapad:
2014-08-05 16:19:50
Ändrad:
2019-11-10 20:10:16
sv

ssmtp

Minimal MTA för att enbart skicka epost från den lokala maskinen till en mail hub.

Källor: | Debian wiki | HowTo | HowTo | Ubuntu packages |

Testat på Ubuntu 12.04 och 14.04. Verkar inte ha uppdaterats sedan 2014.

Innan installation:

ls -l /usr/sbin | grep sendmail
lrwxrwxrwx 1 root    root          18 apr 14 12:09 sendmail -> /home/per/sendmail

Installera:

sudo apt install ssmtp

Efter installation:

ls -l /usr/sbin | grep sendmail
lrwxrwxrwx 1 root    root           5 jul  1  2012 sendmail -> ssmtp

Konfigurera:

sudo nano /etc/ssmtp/ssmtp.conf eller gksudo geany /etc/ssmtp/ssmtp.conf

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
root=me@example.com

# 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=mail
mailhub=mail.example.com:587

AuthUser=me@example.com
AuthPass=myPassword
#UseTLS=YES
#UseSTARTTLS=YES

# Where will the mail seem to come from?
#rewriteDomain=
rewriteDomain=example.com

# The full hostname
hostname=myServer

# 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
FromLineOverride=YES

Testa, ett kommando (byt ut example.com):

echo -e "To: recipient@example.com\nFrom: sender@example.com\nSubject: Test1\n\nThis is the mail body" | /usr/sbin/ssmtp recipient@example.com

eller manuellt:

ssmtp recipient_email@example.com

sSMTP will then wait for you to type your message, which needs to be formatted like this:

To: mottagare@example.com
From: avsändare@example.com
Subject: testar epost

Hej världen!

Note the blank like after the subject field. Everything you type from the Hello World! onwards is the body of the email. Once you have finished composing your email hit Ctrl-D. After a few seconds sSMTP will send the message.

 

cron

När cron (systemet) skickar epost blir avsändaren "From: root (Cron Daemon)", det är inte så bra, fixa det med:

sudo nano /etc/ssmtp/revaliases

root:username@example.com:smtp.example.com:587
localusername:username@example.com:smtp.example.com:587

Verkar inte funka, se annan lösning under cron

PHP

Konfigurera php att andvända ssmtp:

sudo nano /etc/php5/apache2/php.ini

Sök med ctrl+w sendmail_path

sendmail_path = /usr/sbin/ssmtp -t

 

ssmtp beroenden (Ubuntu 14.04)

/usr/bin/ldd /usr/sbin/ssmtp
	linux-vdso.so.1 =>  (0x00007ffef1d7e000)
	libgnutls-openssl.so.27 => /usr/lib/x86_64-linux-gnu/libgnutls-openssl.so.27 (0x00007f637031f000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f636ff5a000)
	libgnutls.so.26 => /usr/lib/x86_64-linux-gnu/libgnutls.so.26 (0x00007f636fc9c000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f637052a000)
	libgcrypt.so.11 => /lib/x86_64-linux-gnu/libgcrypt.so.11 (0x00007f636fa1c000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f636f803000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f636f5e5000)
	libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f636f3d1000)
	libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f636f18f000)
	libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f636ef8a000)
	libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f636ed82000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f636eb7e000)

 

Uninstall

sudo apt --purge remove ssmtp

 

Kommentarer till sidan ssmtp