The sendmail package, which comes preinstalled with many distros, is often simply too much for a simple server that should not receive emails but rather deliver them. The sSMTP package is a lightweight replacement that does not set up regular cronjobs and only reacts if a subsystem actually wants to send a mail.
apt-get purge --yes sendmail*
apt-get install --yes ssmtp
groupadd mail
dpkg-statoverride --update --add root mail 0640 /etc/ssmtp/revaliases
dpkg-statoverride --update --add root mail 0640 /etc/ssmtp/ssmtp.conf
dpkg-statoverride --update --add root mail 0750 /usr/sbin/ssmtp
chmod g+s /usr/sbin/ssmtp
cat << EOF > /etc/ssmtp/ssmtp.conf
# /etc/ssmtp/ssmtp.conf
[email protected]
hostname=host.name
mailhub=smtp.host.name:465
FromLineOverride=YES
[email protected]
AuthPass=password
AuthMethod=LOGIN
UseTLS=YES
EOF
usermod -a -G mail php-user
Change the PHP sendmail configuration in the php.ini
file as follows:
sendmail_path = "/usr/sbin/sendmail -t -i"
A simple test script:
#!/usr/bin/env php
var_dump(mb_send_mail('[email protected]', 'Test Mail from PHP', 'This is a test mail sent from PHP.'));
- Debian Wiki: sSMTP