You may have noticed that when your WordPress site sends emails using PHP's default settings, your emails often don't get delivered. The solution to this problem is to use an external SMTP server to do the actual email sending.
Turns out that setting it up to send from your own custom email address is not as simple as it should be, especially if you want a free solution and don't want to pay for an SMTP server.
This is the free solution I use for most of my sites, once you set it up it works like a charm, and you never have to worry about it again.
These same instructions can be used if you just want to set up your Gmail account to send emails from any email address, for example from an address on a domain that you own. Just start from step 5.
TL;DR Summary: set up the free WP Mail SMTP plugin, set up a Gmail account to send email as any email address you want, connect the two.
Step 1: Install the free WordPress plugin: WP Mail SMTP. The easiest way is to go to your WordPress Dashboard, Plugins, Add New, and search for it. This is what it looks like:
Step 2: Create a free Gmail account. You can use your existing account but I prefer to have a separate account that will be used for sending emails from a website. There are some limitations on the number of emails you can send using a Gmail account, so if you expect to be sending a high volume of emails then go with something like Sendgrid (WP Mail SMTP supports a ton of different email senders).
Step 3: Go through WP Mail SMTP's setup wizard and choose Gmail as the provider. There are a few steps you need to go through there to set up an app in your Gmail account, but the instructions they have are good, just follow them. Make sure you're signed in to your new Gmail account when you do this (I do it all in an incognito window to make sure I don't mix up accounts).
When you're done with this you should have your website sending emails using your Gmail as the SMTP sender.
If you don't want to change the email address that Wordpress uses to send, and are fine with sending from your Gmail address, then you're done.
The rest of the steps are how to change the email address that your website uses as the From email address when sending emails.
These instructions are the way to set up a Gmail account to send emails from any email address, for example from an account on a domain you own.
Step 5: Setup your Gmail account to send email from an alias. You first need to be able to send emails from your Gmail account using the email address that you want to use. There are good instructions for this here: https://support.google.com/domains/answer/9437157. I'll cover the important parts:
Step 6: Set up 2-step verification in your Gmail account. You need this in order to create an App Password for your account. Go to https://myaccount.google.com/security and turn on 2FA.
Step 7: Create an App Password. The App Password will be used by Gmail to send outgoing messages from a different email address. Once 2-factor authentication is turned on you'll have the option to create an App Password in the same security section of your Google account. If you still don't see the option go to the URL: https://myaccount.google.com/apppasswords
Under "App passwords" click Select app and then Mail. Then Select device and then Other. Enter a name and click Generate. Copy that code.
Step 8: Add an account to your Gmail to "Send mail as". The exact instructions to add an email alias are at the same link as in step 5 above https://support.google.com/domains/answer/9437157. The gist of it is to go to your Gmail account and go to Settings->See all settings. Then go to Accounts and Import. Under Send mail as click on Add another email address. Then fill in your name and the email address you want to use. In the SMTP Server field, enter: smtp.gmail.com, use your Gmail address as the username, and use the App Password you created in the previous step as the password. Gmail will then send you a verification email with a code, copy that code and you're done.
Step 9: Change the email address that WordPress uses to send emails with. Finally, you can go back to your WordPress site and go to WP Mail SMTP, and Settings. Scroll down until you see From Email. You should now have a dropdown where you can finally choose the additional email address you added to your Gmail account as the from email your site will be sending emails from.
0 comments:
Post a Comment