Last updated on September 25th, 2019 at 09:41 am
Wcommerce uses the WordPress default Wp-mail() function to send emails. But sometimes Woocommerce emails do not work and sometimes they are marked as spam by Gmail, Yahoo, Hotmail. This makes real pain and even if you contact your hosting provider they won’t help you. So you end up beating your head with a desk. You can solve this issue to integrate Mailgun with WordPress as an email sending server.
MailGun will be integrated with WordPress to send emails to customers upon their order placing. Mail gun allows sending 10000 free emails per month. By using this the emails will be sent to the inbox, not into spam or junk folder. In this article, I’ll explain how you can integrate Mailgun with your WordPress website.
You can set up this by following these steps
- Make Account on Mailgun
- Add Your Domain in Mailgun account
- Installing Mailgun plugin in WordPress
- Adding the APIs and other settings in the Mailgun Plugin
- Sending test email
How to make an account on mailgun
First of all, you need to signup on Mailgun official website, The signup processes is simple it will ask to add credit card details it is optional but I would recommend you to add it shows that you are legit and doing serious business. Once you have created an account it will ask to verify your email and phone number, Verify both of them and your account is ready to use.
Add your Domain in mailgun account
Right after signup, this is a very important and tricky step you need to do it carefully. Login into account and at the left side click on domain tab by default mailgun adds a sandbox subdomain.
You need to add your own domain by clicking add new domain it will open up an interface you where you can add your domain.
Don’t add your actual domain make a subdomain to add there, for example, My domain name is wpsetup.cub I’ll add mail1.wpsetup.club in domain section. Select the US or EU and don’t change the other option go with the default. After adding your domain it will open the DNS page.
Add DNS to your Domain account
After adding the domain name it will show you the DNS record page, you need to add these records into your domain provider account. In my case, I’ve bought the domain from NameCheap. I’ll login my Namecheap account and will go to my specific domain DNS records page.
After landing to your NameCheap DNS records scroll down a little, you will have options to add new records. Open both tabs at the same time the DNS page of mailgun and the DNS page of Namecheap.
First of all copy the hostname of the first record from the mailgun DNS page and navigate to the Namecheap page click on add new TXT record and paste the host in the host section.
After adding all the TXT records its time to add MX records just repeat the steps as you did for TX records. Once you have added all the records click on save settings it will verify the records. If you have made any mistakes while adding them there will be a red mark. But if you have successfully added there will be a green mark.
After the verification Mailgun will open a new tab and will show two options the first option will be for APIs and the second option will be for SMTP set up. Since we are fixing the Woocommerce emails that are not going into customer’s mailboxes so we need Apis.
Adding APIs in Mailgun WordPress plugin.
Once you have copied the APIs from the mailgun website its time to paste them in Plugin’s setting. In the domain, section add the subdomain that you used in the mailgun account. In our case it was mail1.wpsetup.club. In the next tab paste the APIs that you just copied a moment ago. Set no for click tracking and open tracking.
In from address put the email from where you want to send emails. it is always best practice to use the email that on sub-domain it builds trust and loyalty. in the next box put your website name and don’t touch the other options and click on save changes.
After click save changes its time to test the things whether it’s configured properly or not. In order to test click on Test Configuration. if it shows a failed message you should check your DNS settings otherwise you are good to go.
So much satisfaction to see this success message :D. Yes, we have configured it successfully now we can send wocommerce emails to our customers. To test up the things go back to your mailgun account and navigate to your domain and click Logs. There will be detailed stats about your logs if you are getting the green logs Congratulation you have set up everything correctly.
After setting up all the things its time to place a test order and let’s see if we get emails on the customer’s email or not. Wocommerce usually sends two emails on successful order first one is Order Processing Email and the second one is Order Completed Email. So we should get the order processing email right after we finish the checkout process.
That was a quick tutorial about mailgun integration you can use another mail server instead of mailgun and can follow the same steps. If you still have any doubt don’t hesitate to ask in comment.