Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@terwey
Last active July 24, 2017 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terwey/e73a21d28f70fdde609ef09191d20e2f to your computer and use it in GitHub Desktop.
Save terwey/e73a21d28f70fdde609ef09191d20e2f to your computer and use it in GitHub Desktop.
PHP mail with SMTP for Apache/nginx/etc

Setup

apt-get install msmtp

vim /etc/msmtprc

defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt 
account YourSMTP
host smtp.foobar.com
from baz@foobar.com
auth on
user baz
password bazS3cr3tpass

account default: YourSMTP

chmod 0600 /etc/msmtprc

chown www-data:www-data /etc/msmtprc

vim /etc/php/7.0/apache2/php.ini

Change the sendmail_path to: sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t -i"

Restart Apache and you're good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment