WordPress relies on PHP’s mail function by default, which often sends email from your web server without proper authentication. That approach worked fine a decade ago. Today, it lands messages in spam folders or gets them blocked entirely. Major providers like Gmail, Outlook, and Yahoo require proper authentication records, consistent sending reputation, and infrastructure that most shared hosting environments simply cannot provide.
SendGrid solves this by handling the delivery infrastructure for you. They maintain relationships with mailbox providers, manage IP reputation, and provide the authentication framework that modern email demands. Configuring WordPress to route mail through SendGrid’s SMTP service is one of the most impactful changes you can make for deliverability, and the process is straightforward once you understand the moving parts.
Why SMTP Matters for WordPress
The native wp_mail() function uses your server’s local mail transfer agent. On shared hosting, that agent often shares an IP address with hundreds of other sites. If one neighbor sends spam, the entire IP gets flagged. Your password reset emails, contact form submissions, and WooCommerce order confirmations all suffer the consequences.
SMTP (Simple Mail Transfer Protocol) authentication changes the equation. Instead of sending from your web server, WordPress connects to SendGrid’s servers using authenticated credentials. Your email originates from SendGrid’s infrastructure, which maintains dedicated IP pools, automated warmup processes, and compliance teams that work directly with major mailbox providers.
The difference shows up immediately in delivery rates. Sites that switch from unauthenticated PHP mail to authenticated SMTP typically see open rates improve because messages actually reach the inbox rather than the spam folder or, worse, getting silently dropped.
Prerequisites Before You Start
You need an active SendGrid account. The free tier includes 100 emails per day, which covers most small business sites, contact forms, and transactional notifications. If you send more volume, paid plans start at modest monthly rates and include dedicated IP options for high-volume senders.
Your domain must be authenticated in SendGrid before SMTP credentials will work reliably. This means adding DNS records — specifically SPF, DKIM, and DMARC — that prove you own the sending domain. SendGrid provides the exact values in their dashboard under Settings > Sender Authentication. Skip this step, and your emails will still face deliverability issues even though they route through SendGrid’s servers.
You also need administrator access to your WordPress dashboard and, ideally, access to your hosting control panel or FTP in case you need to troubleshoot connection issues at the server level.
Creating SendGrid SMTP Credentials
Log into your SendGrid dashboard and navigate to Settings > API Keys. Create a new API key with “Mail Send” permissions at minimum. Choose “Restricted Access” rather than “Full Access” for security — the key only needs permission to send email, not to manage your account, contacts, or statistics.
Name the key descriptively, something like “WordPress SMTP – example.com” so you can identify it later. Copy the generated key immediately; you won’t see it again. This API key serves as your SMTP password. The username is always “apikey” (literally the word apikey) regardless of what you named the key.
Note the SMTP server address: smtp.sendgrid.net. SendGrid supports ports 25, 587, and 2525 for unencrypted or TLS connections, and port 465 for SSL. Port 587 with TLS is the most widely compatible choice and works on virtually all hosting environments.
Method One: Using a Plugin (Recommended for Most Users)
Plugins handle the configuration details, test the connection, and often provide logging features that make troubleshooting easier. Several solid options exist, but they all work on the same principle: they filter wp_mail() through PHPMailer with your SMTP credentials.
WP Mail SMTP
This is the most popular option, maintained by WPForms. The free version supports SendGrid natively. After installation, go to WP Mail SMTP > Settings. Choose “SendGrid” as your mailer. The plugin will ask for your API key — paste the key you created earlier. It handles the host, port, and encryption settings automatically.
The plugin includes a test email feature. Send a test to an address you control, preferably at Gmail or Outlook, so you can verify inbox placement and check headers for authentication results.
Post SMTP Mailer/Email Log
This alternative offers more granular control and a cleaner logging interface. It supports SendGrid via the “Post SMTP” configuration wizard. Select “SendGrid API” as the transport type, enter your API key, and the plugin configures the rest. Its logging dashboard shows every email attempt with success or failure status, which is invaluable when contact forms stop working.
FluentSMTP
A newer entrant that supports multiple SMTP providers simultaneously. You can route WooCommerce emails through SendGrid while sending newsletter signups through a different service. The setup wizard includes SendGrid as a preset option.
Method Two: Manual Configuration Without Plugins
Some developers prefer avoiding plugins for email routing, either to reduce overhead or because they manage configuration through version control. You can configure SMTP directly in your theme’s functions.php or, better yet, in a site-specific plugin or mu-plugin.
Add this code snippet, replacing the placeholder values:
add_action( 'phpmailer_init', 'configure_sendgrid_smtp' );
function configure_sendgrid_smtp( $phpmailer ) {
if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
return;
}
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.sendgrid.net';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 587;
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Username = 'apikey';
$phpmailer->Password = 'YOUR_SENDGRID_API_KEY';
$phpmailer->From = 'noreply@yourdomain.com';
$phpmailer->FromName = 'Your Site Name';
}
This approach gives you complete control but removes the testing and logging interfaces that plugins provide. You’ll need to trigger a test email manually, perhaps through a custom endpoint or by temporarily adding a wp_mail() call to a template file.
One advantage: this configuration survives plugin deactivations and theme changes if placed in an mu-plugin (a PHP file in wp-content/mu-plugins/). However, it also means you cannot easily disable SMTP for testing without editing code.
Verifying the Configuration
After saving your settings, send a test email. Check the raw headers of the received message. In Gmail, open the message, click the three-dot menu, and select “Show original.” Look for these indicators:
- SPF: Should show “pass” with your domain
- DKIM: Should show “pass” with a SendGrid selector (typically
s1._domainkeyor similar) - DMARC: Should show “pass” if you’ve configured a DMARC record
- Received headers: Should show SendGrid servers (e.g.,
o1.sendgrid.net,o2.sendgrid.net)
If authentication shows “fail” or “neutral,” revisit your SendGrid sender authentication settings. The DNS records must be fully propagated and correctly formatted. Use a tool like MXToolbox or Google’s Check MX to verify your domain’s records from an external perspective.
Common Issues and Fixes
Connection Timeout or “Could Not Connect to SMTP Host”
Your hosting provider may block outbound connections on port 587. This is common on some shared hosting platforms and managed WordPress hosts. Try port 2525 instead — SendGrid keeps it open specifically for this scenario. If that fails, contact your host’s support and ask them to allow outbound SMTP to smtp.sendgrid.net on ports 587 and 2525.
Authentication Failed
Double-check that you’re using “apikey” as the username (not your SendGrid username or email) and that the API key has Mail Send permissions. Regenerate the key if you suspect it was copied incorrectly. Keys with special characters sometimes cause issues in certain PHP configurations; generating a new key often resolves this.
Emails Send but Don’t Arrive
Check SendGrid’s Activity Feed in the dashboard. It shows every message attempt with delivery status: delivered, bounced, blocked, deferred, or processed. If SendGrid shows “delivered” but the recipient doesn’t see it, the issue is on the receiving side — check spam folders, promotional tabs, and the recipient’s filtering rules.
From Address Rejected
SendGrid requires the From address to match a verified sender identity. In Settings > Sender Authentication, verify either your entire domain (preferred) or individual email addresses. If you verify the domain, any address @yourdomain.com works. If you verify single addresses, each From address must be added individually.
Advanced Configuration Options
Categories and Custom Arguments
SendGrid’s API supports categories for grouping emails (e.g., “password-reset,” “order-confirmation,” “newsletter”) and custom arguments for metadata. Plugins like WP Mail SMTP Pro expose these fields. With manual configuration, you’d need to hook into phpmailer_init and add custom headers:
$phpmailer->addCustomHeader( 'X-SMTPAPI: {"category": "password-reset", "unique_args": {"user_id": "123"}}' );
This data appears in SendGrid’s statistics and webhook payloads, enabling granular delivery analysis.
Dedicated IP Addresses
High-volume senders (typically 100,000+ emails/month) benefit from dedicated IPs. SendGrid includes one with Pro plans and above. A dedicated IP isolates your reputation from other senders, but it requires consistent volume to maintain. If you send irregularly, a shared IP pool is actually better because SendGrid’s automated warmup keeps the reputation healthy.
Subuser Accounts for Agencies
Agencies managing multiple client sites should use SendGrid subusers. Each subuser gets its own API keys, statistics, and IP reputation. The parent account controls billing and can enforce settings across subusers. This prevents one client’s poor list hygiene from affecting another client’s deliverability.
Security Considerations
Store API keys securely. Never commit them to version control. Use environment variables or WordPress constants in wp-config.php:
define( 'SENDGRID_API_KEY', 'your-key-here' );
Then reference SENDGRID_API_KEY in your configuration code. This keeps credentials out of your database and codebase.
Rotate API keys periodically, especially if team members change. SendGrid allows multiple active keys, so you can create a new one, update your configuration, then revoke the old one without downtime.
Enable two-factor authentication on your SendGrid account. Compromised SendGrid credentials allow attackers to send spam from your domain, destroying your sending reputation and potentially getting your domain blocklisted.
Monitoring and Maintenance
Check SendGrid’s dashboard weekly. Monitor bounce rates (should stay under 2%), spam complaint rates (under 0.1%), and block rates. Sudden spikes indicate problems — perhaps a contact form is being abused, or a transactional email template triggers spam filters.
Set up event webhooks to send delivery data to your own analytics or monitoring system. SendGrid can POST events (delivered, opened, clicked, bounced, blocked, spam report, unsubscribe) to an endpoint you control. This lets you build custom dashboards or trigger alerts when metrics exceed thresholds.
Review your suppression lists monthly. SendGrid automatically suppresses addresses that hard bounce or generate spam complaints. Occasionally, legitimate addresses end up there due to temporary issues. You can manually remove them if appropriate.
When to Consider Alternatives
SendGrid excels at transactional email. If your primary need is marketing campaigns — newsletters, promotional blasts, automated sequences — platforms like Mailchimp, ActiveCampaign, or ConvertKit provide better list management, segmentation, and compliance tools. They also include SMTP endpoints, so you can still route WordPress transactional mail through them.
For developers who want more control, alternatives include Mailgun, Postmark, and Amazon SES. Postmark focuses exclusively on transactional email with exceptional deliverability and a generous free tier. Amazon SES costs pennies per thousand emails but requires more setup and reputation management. Mailgun sits between SendGrid and Postmark in features and pricing.
If you’re already invested in the Twilio ecosystem (SendGrid’s parent company), SendGrid integrates naturally with Twilio’s other communication APIs. That synergy matters for teams building multi-channel notification systems.
Frequently Asked Questions (FAQs)
Do I need a paid SendGrid plan for WordPress SMTP?
The free tier provides 100 emails per day, which covers most small business sites, contact forms, and typical transactional emails like password resets and order confirmations. If your site sends more — for example, a membership site with daily notifications or a high-traffic WooCommerce store — you’ll need a paid plan. The Essentials plan starts at a low monthly cost and includes 40,000 emails per month.
Can I use SendGrid SMTP with a contact form plugin like Contact Form 7 or Gravity Forms?
Yes. Once SMTP is configured at the WordPress level, any plugin that uses wp_mail() automatically routes through SendGrid. This includes Contact Form 7, Gravity Forms, WPForms, Ninja Forms, and WooCommerce emails. No additional configuration in the form plugin is required.
Why are my emails still going to spam after configuring SendGrid?
SMTP authentication is necessary but not sufficient. Check that your domain has proper SPF, DKIM, and DMARC records configured in DNS and verified in SendGrid’s Sender Authentication settings. Also examine email content: excessive links, spam trigger words, poor text-to-image ratios, and missing unsubscribe links can all trigger spam filters regardless of delivery infrastructure.
What happens if SendGrid’s API is down?
Your WordPress site will be unable to send email until the service recovers. SendGrid maintains a strong uptime record, but no service guarantees 100% availability. For mission-critical emails (password resets, security alerts), some developers implement a fallback: queue emails locally and retry, or configure a secondary SMTP provider as backup. Most sites accept the minimal risk given SendGrid’s reliability.
Can I send from multiple domains through one SendGrid account?
Yes. Verify each domain in SendGrid’s Sender Authentication settings. Each domain gets its own DKIM keys and SPF records. When sending email, ensure the From address matches one of your verified domains. SendGrid will apply the appropriate authentication for that domain automatically.
Do I need to change my DNS records if I’m only using SMTP (not the API)?
Yes. SMTP delivery still requires domain authentication. The receiving mail servers check SPF, DKIM, and DMARC regardless of whether you submit mail via SMTP or API. Without these records, your emails face the same deliverability issues as unauthenticated PHP mail, just originating from SendGrid’s IPs instead of your server.
How do I debug emails that aren’t sending?
Start with SendGrid’s Activity Feed — it shows every submission attempt and its status. If the email appears there as “processed” or “delivered,” the issue is downstream. If it doesn’t appear, check your WordPress error logs and the SMTP plugin’s logs (if using one). Enable WP_DEBUG_LOG temporarily to capture PHPMailer connection errors. Common culprits: blocked outbound ports, incorrect API key, or unverified sender identity.
Is it better to use the SendGrid API or SMTP for WordPress?
For WordPress, SMTP is generally simpler because it works with the existing wp_mail() function and requires no code changes. The API offers more features (categories, custom args, template engine) but requires a plugin or custom code that integrates with SendGrid’s PHP library. Most sites don’t need API-specific features. If you need advanced functionality like transactional templates or detailed event tracking, the API approach is worth the extra setup.