Well this has always been a little bit of a mystery to me. When you work with WordPress, it eventually does like to send mail to folks as an administrator. How do you make this work.
If you are using Amazon AWS Lightsail, the default Bitnami image has something called WP Mail SMTP preloaded. You use this to use your gmail to send mail.
I'm not quite sure how DigitalOcean does it, but whatever it does, it doesn't seem to work. And they seem to suggest that you need to do this through Gmail.
Doing this is actually pretty complicated because you have to enable the Google Gmail API, then get a secure Oauth credential and make sure it only works again your website, so others can't hammer away and send mail. They have a nice guide for it, but here are the short instructions:
- First you need to install the WP Mail SMTP plugin and then you will need to have that window open as it has the important redirect URI
- Now start Google developers window and if you have not activated this service, you need to start it and you will need a credit card for future billing.
- At this point, you need to go to the Credentials section and choose OAuth. This will then let you add for a web server. Type in the name and then you will get the domains from which a request from come. Normally this is just the single website to prevent others from using your mail account.
- When you choose save, you are going to get thrown back to the main screen. Click on Credentials
- Then click on create credentials and choose OAuth 2.0 Client Id. Here you need to put in your URI but the most important entry is Authorized redirect URI. This is the link that Google returns to if the OAuth succeeds.
- Now you can go back to the Credentials section and click on your Client ID for Web application and to the left you will see the two things you need. The first is the Client ID which is a huge number. Paste that into the WordPress SMTP plugin page as the login as the Client ID.
- Then there is the secret which is basically the password. Paste that into the Client Secret text box and choose save settings.
What have you done here? Well on the Google side, you created an entry point for Gmail and you connected that to a login screen. You also gave Google a URL to return to if the access is succcessful.
Then on the WordPress site, you gave it a user name (Client ID) and login password (the Client Secret) that is used to login to Google, then launch the access request.
So all that is left is to test if. Scroll down to the bottom of the plugin and click on Authorize and you should see a Google login screen that will allow access. If this works, you will be return to your website and it should say Connected to whatever your email is. Eureka!
Now click on Save and then the Email Test tab and see if you can get mail.