Using a SMTP server to send Gravity Forms notifications
March 13th, 2015
Gravity Forms, like almost all other WordPress plugins, uses the WordPress core function wp_mail() to send all the emails. So the process of sending the email is not controlled by Gravity Forms, is WordPress really who is going to ask your server to send the emails.
Web hosting companies don’t expect you to use their servers to send a large number of emails from your site, specially if you’re in a shared hosting plan, they mainly provide you the email service to be used by you as “human”. Also due to the limitations and restrictions that some hosting companies puts on their SMTP servers to prevent abuse and spam, it’s not a good idea to use the SMTP provided by your hosting company, you can easily be considered a spammer by your hosting just because you’re sending large amounts of emails. So if you’re receiving many form entries per day it’s easy to have email delivery problems due to the mentioned limitations and restrictions set in the server.
So in this little guide we’re going to use a method that will make WordPress to send Gravity Forms notifications, and any other email sent using wp_mail() core function, through a third-party SMTP server instead of using your web hosting resources.
Third-party services and SMTP servers that you can try
All the services below are offering SMTP servers to send transactional emails:
- Sendgrid ( official WP plugin: SendGrid )
- Mailgun ( official WP plugin: Mailgun for WordPress )
- SparkPost ( official WP plugin: SparkPost )
- MailJet ( official WP plugin: MailJet )
- sendinblue ( official WP plugin: SendinBlue Subscribe Form And WP SMTP )
- Elastic Email
- Pepipost ( official WP plugin: Pepipost )
Things that you need to follow this tutorial:
- An account for any of the third-party services mentioned in this article.
- Username, password, hostname, port, and encryption type of the SMTP server that you want to configure.
- A plugin to put this details, in this article we’re going to use SAR Friendly SMTP (created by me) that you can install from your WordPress dashboard. Don’t forget to give it a good rating if you find it useful.
As an example I’ll show how to use SAR Friendly SMTP with the SMTP server provided by Sendgrid and with Gmail (the same applies for Google Apps accounts), although using Gmail SMTP server is not always a good choice, but I’ll explain how to configure it because it’s very popular. Configuring the plugin using any other service is pretty the same, you just need to use the appropriate SMTP server details provided by the third-party service of your choice.
USING SENDGRID SMTP SERVER
SendGrid is a well known transactional email service, that means you can use their API or their SMTP server for delivering emails. They offer a free account (no credit card required) that allows you to send up to 12.000 emails per month and cheap prices if you need to send more.
So we can start by using their free account that works pretty fine and provides us with a reliable SMTP server and also additional information that will be very useful when peforming troubleshooting.
These are the settings for using Sendgrid SMTP server:
- Username: Enter your Sengrid username here.
- Password: Your Sengrid password here.
- SMTP Server: smtp.sendgrid.com
- Port: Enter value 465
- Encryption: Set it to SSL
And we’re done with the server details. You can save changes and go to Tools -> Send Email Test to make a sending test.
By going to your SendGrid account and clicking in the Activity menu option at the left side of the screen you can see a log of the emails handled by SendGrid and their status. If all goes ok you should see Processed and Delivered for each email sent to the SendGrid SMTP server.
In addition to the above setup using SAR Friendly SMTP plugin SendGrid also has an official plugin for WP that allows you to send the emails using their API, but I don’t have tested it so I can’t tell you how it works. What I use on my sites is the above setup with SAR Friendly SMTP and never had a problem.
USING Gmail SMTP server
This is a common setup but it’s not recommended for the following reasons:
- Google only allows you to send emails using your account email address in the FROM header. That means if your Gmail account is email@example.com that will be used always as from address. No matter what you put in your notifications or in the SMTP settings, Google will replace any address in the from field with your account address.
- Gmail has from long time ago a known issue regarding to Reply-To field in the email header, causing to ignore the Reply-To field in the email if your FROM field has any email configured in your Gmail account, and to make it more weird, sometimes this is only an intermittent issue. (If you search in Google you’ll find a lot of people talking about it).We can’t control what Gmail does, but this can be sorted out by simply using in the FROM address field an email different from the ones configured in your Settings -> Accounts (at your Gmail email account). But as we have mentioned above, you can’t do this using the Gmail SMTP server.
- To prevent spammers from using their servers, Google applies additional restrictions to the number of emails you can send per day and also to the number of recipients addresses you can include in each email.
So as you can see it’s better to avoid the use of Gmail SMTP server.
If you think you’ll be ok using Gmail SMTP server, these are the details you need to configure in SAR Friendly SMTP settings page:
- Username: Put your full email address as username, i.e. firstname.lastname@example.org
- Password: Just put the password for your Gmail account 🙂
- SMTP Server: For Gmail/Google Apps put smtp.gmail.com
- Port: Enter value 587
- Encryption: Set it to TLS
And we’re done again with the server details. You can save changes and go to Tools -> Send Email Test to make a sending test.
Additional tips to improve your email deliverability and reputation
Below you can find some tips that will help you to avoid to be considered a spammer by most email providers.
- Configure the SPF record in your domain to validate the source of your emails. Some the above services will force you to do it before using them, but even for the ones that don’t force you to do it, it’s a good practice and recommended.
- Don’t use the email address of your users in your from address in the Grativy Forms notifications setting. That is what spammers do! Use always an email that belongs to your site domain. You can use the Reply To setting to store your user’s email address.
- Don’t use an email subject with ALL CAPITAL LETTERS. Again is something that spammers do and spam filters can take this into account.