# How to use Gmail or Amazon SES with Magento

URL: https://sohaib.com/blog/how-to-use-gmail-or-amazon-ses-with-magento
Author: Sohaib Khan
Published: Jul 10, 2016
Updated: Sep 8, 2026
Category: E-commerce Solutions

> Let's configure Gmail or Amazon SES with Magento2 or Magento 1 or any other php application, basically will configure our server in a way so any php application will then use local php mail but email will route with…

Let's configure Gmail or Amazon SES with Magento2 or Magento 1 or any other php application, basically will configure our server in a way so any php application will then use local php mail but email will route with any SMTP provider. Step 1

```bash
apt-get install msmtp -y
```

```bash
apt-get install libxml-xpath-perl  -y
```

```bash
nano ~/.msmtprc
```

Now will edit or add .msmtprc file

```bash
account gmail
tls on
tls_certcheck off
auth on
host smtp.gmail.com
port 587
user yourusername@gmail.com
from youruser@gmail.com
password Yourpasswordhere
```

Let's change permission and give proper ownership and copy the file to appropriate location

```bash
chmod 600 ~/.msmtprc
cp -p ~/.msmtprc /etc/.msmtp_php
chown www-data:www-data /etc/.msmtp_php
```

Now will edit php.ini file so we can tell sendmail to use our Gmail SMTP I am using PHP 7 so my location is different then your's probably, if you are using Ubuntu or any flavor you can simply use

```bash
locate php.ini
```

 

```bash
nano /etc/php/7.0/fpm/php.ini
nano /etc/php/7.0/cli/php.ini
```

Now will edit sendmail in php.ini

```bash
sendmail_path = "/usr/bin/msmtp -C /etc/.msmtp_php --logfile /var/log/msmtp.log -a gmail -t"
```

Lastly will make sure to have our log file

```bash
touch /var/log/msmtp.log
chown www-data:www-data /var/log/msmtp.log
```

Now goto your Magento2 admin or Magento admin or any PHP Application to try to sendmail email it will use Gmail or Amazon SES to send emails out, you just need to modify your msmtp file
