Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Last active October 31, 2019 22:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudiosanches/7477088 to your computer and use it in GitHub Desktop.
Save claudiosanches/7477088 to your computer and use it in GitHub Desktop.
Ubuntu - PHP email with Gmail.

Install

sudo apt-get install ssmtp

Configuration

Open /etc/ssmtp/ssmtp.conf.

sudo vi /etc/ssmtp/ssmtp.conf

Replace with:

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=****@gmail.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=smtp.gmail.com:587

AuthUser=****@gmail.com
AuthPass=****
UseTLS=YES
UseSTARTTLS=YES

# The full hostname
hostname=localhost

# 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

Open /etc/php/7.3/apache2/php.ini.

sudo vi /etc/php/7.3/apache2/php.ini

Search for ;sendmail_path and replace with:

sendmail_path = /usr/sbin/ssmtp -t

Restart apache:

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