PHP mail() with MSMTP

PHP mail() made easy without a whole mail delivery system like sendmail or postfix.
Use msmtp
Lightweight easy to install and configure.

Installation for LFS:

# wget
# tar -xvf msmtp-1.4.30.tar.bz2
# cd msmtp-1.4.30
# autoreconf -i
# ./configure --prefix=/usr
# make
# make install

Configuration for non authorized smtp access to your smtp provider:
ie. No username/password not encrypted.

Edit or create /usr/etc/msmtprc

And put the following in it.

# msmtp configuration file
# Set default values for all following accounts.
tls off
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
#logfile /var/log/maillog/msmtp.log

# The SMTP server of the provider.
account provider
auth off
#user 123456789
#passwordeval gpg -d ~/.msmtp.password.gpg

# Set a default account
account default : provider

You will have to change with your smtp provider and change with your own valid email address.

Next you will have to tell php to use msmtp.
Edit /etc/php.ini
Search for the line that starts with:
uncomment it and/or change the line to this.

sendmail_path = "/usr/bin/msmtp -t"

Restart your httpd to activate the php changes.
Done !

Happy php mail()ing 🙂

Leave a Reply

Your email address will not be published.

64 − 63 =