WordPress SMTP Configuration

If your site has an open registration or a forum with notifications, then the site probably sends a lot of emails. All of them, by default, are sent via the standard system transport. Such a simple approach does not require additional settings, and emails are sent very quickly. However, it also imposes serious disadvantages.

With the growth in the number of letters and their importance, such an approach can already be called admissible with a stretch, and cases of problems are not uncommon. For example, your emails sent by the site may end up in the spam or not reach the recipient at all.

In most cases, sending emails through third-party services, such as Gmail or Yandex Mail for Domain (PDD), can be the solution. You can also set up sending emails through your own mail server, which, as a rule, is even on the simplest web hosting.

Disadvantages of sending emails via system transport

As noted above, sending emails in WordPress, by default, works without additional settings, but the price for this is very high.

Emails may end up in spam

All spam filters and methods for checking emails that work, for example, on Yandex Mail or Gmail, are probably known only to employees of these companies. Despite the large number of tools for checking incoming shipments, closed from prying eyes, there are several things that can increase the trust of the mail service in your letters.

A letter sent via system transport does not contain additional electronic signatures that may indicate the reliability and legitimacy of the sender. Perhaps, many people know that anyone can send a letter from someone else’s address, for example, from admin@wpmag.ru without having any access to the domain itself and the site.

Sending emails through a mail service will automatically add DKIM signatures that testify to the reliability and legitimacy of the sender. Sending servers (SMTP servers) Yandex Mail and Gmail automatically add DKIM signatures to each message. With them, only the owner of the domain (and the DKIM private key) can send emails with valid DKIM signatures.

DKIM signatures do not change the fact that someone else can send an email using your address (admin@wpmag.ru), but the receiving mail server will see that someone else sent the email, not the domain owner.

SPF records are set in the domain settings (DNS) and allow the domain owner to show mail services from which servers messages from this domain can be sent. Each mail service offers its own SPF record with its own list of servers. If you send letters via Yandex mail and send mailings via Mailchimp, then you need to combine their SPF records into one.

Letters may disappear.

Another trick used by mailers to screen out bad emails is Greylisting. Here, at the time of sending the letter, the receiving server can respond to your site with something like “I’m busy now, come back with this letter in ten minutes.” The site does not know what to do in this case – the letter was sent for sending, that’s all, so the sent letter will simply disappear and will not be delivered to the addressee.

If your email is sent by mail service, then your sending server will say “ok google”, but the email in the backlog queue and try to deliver it a few more times. The calculation is simple – when sending a huge amount of mail in a short period of time, as spammers usually do, there is no time to try to deliver the letter several times.

The letter may not reach even if the receiving server is simply turned off for a while or has lost access to the network. Therefore, sending emails via SMTP is more reliable.

Sending emails via SMTP

There is no fundamental difference between sending through an external mail service (Yandex Mail, Gmail) or your own SMTP server. This is the same. But if you decide to use your own or a dedicated hosting SMTP server, you should carefully consider its settings. Be sure to set the correct DKIM and SPF records in the domain settings.

Google and Yandex do not prohibit sending emails through their servers in this way, but they have some limits on the number of messages sent per day. For example, Gmail has an explicitly stated limit of 2000 emails per day. Yandex does not provide specific figures, and the support service hinted that this figure is dynamic.

Note that connections to external servers are blocked on many hosting sites (information can be obtained from hosting support or using the command telnet). In this case, you can ask for hosting support to allow connections. Sometimes such requests may be taken into account. Or use the internal mail server provided by the hosting provider. As a rule, it will work even faster than an external one, because it is usually located on the same physical server as your site (webserver).

From personal experience, it was noticed that Yandex Mail for Domain does not save letters sent via an SMTP server in the outbox, but Gmail does.

WP Mail SMTP Plugin

All emails in WordPress are sent using the wp_mail(), which is powered by the popular PHP Mailer library. To allow WordPress to wp_mail()send emails via an SMTP server, you need to install and configure the WP Mail SMTP plugin from the official WordPress directory.

After activating the plugin, go to SettingsEmail in the control panel.

Let’s set it up on the Advanced Email Options page. Below is a description and required values ​​for each item.

  • From Email – the address from which letters will be sent and to which the recipient will send a response by clicking on the “Reply” button in his mail.
  • From Name – The name of the sender, you can specify the name of the site or your first and last name.
  • Mailer – sending emails via system transport (function mail()) or via SMTP server. Select “Send all WordPress emails via SMTP“.
  • SMTP Host – SMTP server address. You can find out from the support service or in the help section. For Yandex Mail, use smtp.yandex.ru, for Gmail – .smtp.gmail.com
  • SMTP Port — SMTP server port, depends on the Encryption type. For Yandex Mail and Gmail, use port 465.
  • Encryption – type of encryption. For Yandex mail and Gmail, you must install “Use SSL encryption”.
  • Authentication – whether authorization is required on the mail server. Set “Yes: Use SMTP authentication”.
  • Username – login from the mail. As a rule, the full mailbox address must match the value specified in the From Email field.
  • Password – mailbox password.

After saving the settings, you can send a test email. To do this, enter the address of your mailbox and click the “Send Test” button. A small letter will be sent to the specified address, and service information with the results will appear on the screen. Check if the letter has arrived at the specified address? If not, then something is configured incorrectly and WordPress will not be able to send emails.

Also see: How to Disable Emoji in WordPress

Using the received test letter, you can check whether DKIM and SPF are configured correctly. To do this, open the source code of the letter. In Gmail, this is called “Show Original”. In Mail “Letter properties”.

Email headers should contain the string “Authentication-Results”. If DKIM and SPF are configured correctly, you will see spf=passand dkim=pass.

Authentication-Results: mx.google.com;mx . google . com ;
spf=pass (google.com: domain of mail@armyofselenagomez.com designates 2a02:6b8:0:1630::18 as permitted sender) smtp.mail=mail@armyofselenagomez.com;google . com : domain of mail@armyofselenagomez.com designates 2a02:6b8:0:1630::18 as permitted sender) smtp.mail=mail@armyofselenagomez.com;
dkim=pass header.i=@armyofselenagomez.com

The mail shows a green checkmark next to the letter if the DKIM signature is correct.

Useful materials and conclusion

Sending emails through an SMTP server is a more reliable and correct way to deliver emails. To use SMTP, it is not necessary to understand the configuration and administration of mail servers. Yandex and Google services do a good job with the task and for a small project, this is what you need.

Setting up DKIM and SPF is a topic for a separate article. Setup guides can usually be found in the help sections of mail services or asked from the hosting provider’s support service.

In the popular cPanel hosting management system, mail settings are moved to the “Mail” section. The Email Authentication tab allows you to manage DKIM and SPF settings.

If you have any questions while setting up and reading the article, please write a comment and we will try to help. You can also share your stories about the problems you encountered when sending emails from the site.


Leave a comment

Your email address will not be published. Required fields are marked *