SMTP Cheatsheet
Website not sending mail? Maybe time to implement SMTP.
Website not sending mail? Having a broken contact form on your website is like running a marathon but refusing to cross the finish line. Its frustrating for everyone involved. And is a pointless act of self sabotage. Anyhoo, we digress. SMTP ensures your mail is sent.
What is SMTP?
SMTP (Simple Mail Transfer Protocol) is a protocol used for sending and transmitting email messages between servers. It’s responsible for the delivery of emails to the recipient’s mail server. Here’s a quick overview of how SMTP works:
Sending email: When you send an email, your email client (like Gmail, Outlook, or Thunderbird) connects to an SMTP server to relay the email.
Transporting email: The SMTP server takes care of transmitting your email to the recipient’s email server by following a series of steps, ensuring the message is delivered across networks.
Receiving server: Once the email reaches the recipient’s server, it is held there until the recipient retrieves it using protocols like IMAP or POP3.
In simple terms, SMTP is like the mailman that takes your letter (email) and delivers it to the correct address (the recipient’s email server).
What are the benefits of using smtp for sending email from a Wordpress Website
Using SMTP for sending emails from a WordPress website offers several benefits compared to relying on the default PHP mail function. Here’s why SMTP is a great choice:
1. Improved Email Deliverability
Avoid Spam Filters: Emails sent via the default PHP mail function often end up in spam or junk folders because they lack proper authentication. SMTP uses proper authentication protocols like SPF and DKIM
, which significantly improve the chances of your emails reaching inboxes. Reliable Delivery: SMTP is more reliable than PHP mail for delivering emails consistently, ensuring that important notifications, contact form submissions, and order confirmations are not lost.
2. Authentication and Security
Encrypted Connections: SMTP supports secure email transmission via SSL/TLS encryption. This keeps the content of your emails safe and prevents them from being intercepted or tampered with during transmission. Authenticated Emails: Since SMTP requires credentials (username and password) for sending emails, it adds an extra layer of security, reducing the chance of email spoofing or unauthorized use.
3. Integration with Third-Party Email Services
Use Trusted Providers: SMTP allows you to integrate with well-known email service providers (like Gmail, Outlook, SendGrid, or Mailgun), leveraging their infrastructure for better email deliverability, analytics, and handling larger volumes of emails. Scalability: If your WordPress site needs to send many emails (for example, newsletters or notifications), SMTP through a dedicated service provider ensures that your emails are sent without hitting server limits.
4. Debugging and Error Reporting
Email Logs: Many SMTP plugins for WordPress allow logging of sent emails, making it easier to track delivery success, bounce rates, and errors. Detailed Error Messages: SMTP provides more detailed error messages if something goes wrong during email transmission, helping you troubleshoot issues more effectively.
5. Bypassing Hosting Limitations
Server Restrictions: Many shared hosting providers limit or block the PHP mail function to prevent spam, while SMTP allows you to bypass these limitations by using external mail servers. Avoid IP Blacklisting: Sending large volumes of email via the PHP mail function can sometimes cause your hosting server’s IP address to be blacklisted. SMTP helps avoid this by routing through dedicated mail servers.
6. Customization and Flexibility
Custom Email Settings: With SMTP, you can configure specific settings like the “from” name and email address, giving you more control over the branding and appearance of your emails. Better Tracking: SMTP can integrate with email services that provide detailed analytics, such as open rates, click-through rates, and bounce tracking.
Using an SMTP plugin on your WordPress site ensures more reliable, secure, and professional email communication. Popular SMTP plugins include WP Mail SMTP
, Easy WP SMTP
, and Post SMTP Mailer/Email Log
.
Troubleshooting
- Is port 25 blocked? if port 25 is blocked the server cannot send email.
- There could be multiple form plugins on the site. Ensure your testing / configuring the correct form.
- Is the server able to send email? Try doing a simple Password reset or Send a test mail. Test server is able to send email install https://wpmailsmtp.com/. Search for
wpmailsmtp
to install. set it to use plain php, and use the test email function. This will also give you an error log. - Change the receiving email address. Sometimes issues arise if forms have the same to/from sender.
Tools to send email tests.
Checking if mail is sending from the server is critical.
- make a change
- see if it works by sending a test mail
- make a change
see if it works ..
- Fluent Install fluent smtp plugin and configured that over the WP-Mail SMTP.
- WP Easy Smtp
SMTP using Gmail
If you have a gmail or google workspace your sweet. You can send mail from your website using google / gmail via Google API. You need to connect the wp-mail-smpt plugin to google Using OAuth
credentials.
WP Mail SMTP
Use Gmail to send email from website
To set up Gmail as the mailer for sending emails from your WordPress site using the WP Mail SMTP plugin, follow these steps:
Step 1: Install and Activate WP Mail SMTP Plugin
- Go to your WordPress dashboard.
- Navigate to Plugins > Add New.
- Search for “WP Mail SMTP”.
- Click Install Now, then Activate.
Step 2: Configure WP Mail SMTP Settings
- Go to WP Mail SMTP > Settings in your WordPress dashboard.
- Under the Mailer tab, select “Google / Gmail”.
- You will need to set up a Google app to get the required Client ID and Client Secret.
Step 3: Create a Google App
- Visit the Google Cloud Console.
- If you haven’t already, create a project:
- Click Select a Project, then New Project.
- Name your project and click Create.
- Enable the Gmail API:
- From the left menu, go to Library.
- Search for “Gmail API” and click on it.
- Click Enable.
- Configure OAuth Consent Screen:
- From the left menu, go to OAuth consent screen.
- Choose External, then click Create.
- Fill in the App Name, User Support Email, and other details.
- Click Save and Continue until the end, and then Back to Dashboard.
- Create Credentials:
- From the left menu, go to Credentials.
- Click on Create Credentials and choose OAuth 2.0 Client IDs.
- Choose Web application as the Application Type.
Add the https://connect.wpmailsmtp.com/google/
to redirect url under Credentials > OAuth 2.0 Client IDs > project-name > Authorized redirect URIs
Authenticate smtp
In website smtp settings click the big orange btn to authenticate smtp
Send test email
Go to tools and send test email
Improve sending
add spf record to your domain
1
2
3
type: TXT
name: @
content: v=spf1 include:_spf.google.com ~all
If you have an existing spf record you will need to combine the two by adding the +include:_spf.google.com
part to your existing record.