SendGrid SMTP Settings (2026)
Complete guide to configure Twilio SendGrid SMTP relay for transactional and marketing emails. Includes API key setup, domain authentication, and code examples for all major languages.
table_chart SendGrid SMTP Quick Reference
| SMTP Server | smtp.sendgrid.net |
| Port (STARTTLS) |
587
check_circle
Recommended
|
| Port (SSL/TLS) | 465 |
| Alternative Ports |
2525,
25
(if 587 blocked)
|
| Username |
apikey
(literal string)
|
| Password | Your SendGrid API Key (SG.xxx...) |
| Encryption | TLS 1.2+ required |
| Authentication | PLAIN / LOGIN |
Username is Always 'apikey'
A common mistake: the SMTP username must be the literal word apikey, NOT your email address or account name. Your API key goes in the password field.
checklist Prerequisites
- check_circle SendGrid account - Sign up free
- check_circle API key with 'Mail Send' permission
- check_circle Verified Sender Identity (email or domain)
- info Domain authentication recommended for better deliverability
integration_instructions Step-by-Step Setup
Create an API Key
- 1. Go to Settings → API Keys
- 2. Click "Create API Key"
- 3. Name your key (e.g., 'SMTP Relay')
- 4. Select "Restricted Access" and enable only "Mail Send"
- 5. Click "Create & View"
warning Critical: Copy your API key immediately! It starts with 'SG.' and will only be shown once. Store it securely.
Verify Sender Identity
SendGrid requires sender verification. Choose one method:
person Single Sender
Quick setup for testing. Verify one email address.
- + Fast to set up
- - Only one 'From' address
- - Shows 'via sendgrid.net'
domain Domain Authentication Recommended
Best for production. Authenticate your entire domain.
- + Any address @yourdomain.com
- + Better deliverability
- + Custom DKIM signing
Domain Authentication (Recommended)
- 1. Go to Settings → Sender Authentication
- 2. Click "Authenticate Your Domain"
- 3. Select your DNS provider and enter your domain
- 4. Add the CNAME records to your DNS
Required DNS Records (Example)
| Type | Host | Value |
|---|---|---|
| CNAME | em1234.yourdomain.com | u1234567.wl001.sendgrid.net |
| CNAME | s1._domainkey.yourdomain.com | s1.domainkey.u1234567.wl001.sendgrid.net |
| CNAME | s2._domainkey.yourdomain.com | s2.domainkey.u1234567.wl001.sendgrid.net |
* Actual values will be provided by SendGrid during setup
Configure Your SMTP Client
Use these settings in your email client or application:
smtp.sendgrid.net
587
apikey
SG.xxxx...
code Code Examples
# pip install python-dotenv
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import os
# SendGrid SMTP Configuration
SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY')
SMTP_SERVER = 'smtp.sendgrid.net'
SMTP_PORT = 587
SMTP_USERNAME = 'apikey' # Always 'apikey'
def send_email(to_email, subject, body):
msg = MIMEMultipart('alternative')
msg['From'] = 'sender@yourdomain.com'
msg['To'] = to_email
msg['Subject'] = subject
# HTML content
html_part = MIMEText(body, 'html')
msg.attach(html_part)
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
server.starttls()
server.login(SMTP_USERNAME, SENDGRID_API_KEY)
server.send_message(msg)
print('Email sent successfully!')
# Usage
send_email(
'recipient@example.com',
'Hello from SendGrid',
'<h1>Welcome!</h1><p>This is a test email.</p>'
)
star SendGrid SMTP Features
SendGrid supports special SMTP headers for enhanced functionality:
X-SMTPAPI Header
Add categories, scheduling, and tracking via JSON header:
{
"category": ["marketing", "newsletter"],
"send_at": 1704067200,
"unique_args": {"campaign": "jan2026"}
}
category Categories
Tag emails for analytics grouping. Up to 10 categories per email.
schedule_send Send Later
Schedule emails up to 72 hours in advance with send_at timestamp.
analytics Click Tracking
Automatic open and click tracking. View stats in SendGrid dashboard.
unsubscribe Unsubscribe Groups
Manage subscription preferences with ASM groups.
payments SendGrid Pricing (2026)
| Plan | Emails/Month | Price | Features |
|---|---|---|---|
| Free | 100/day | $0 | Basic analytics, single sender |
| Essentials | 40,000 - 100,000 | $19.95+/mo | Domain auth, email support |
| Pro | 100,000 - 1.5M | $89.95+/mo | Dedicated IP, subuser mgmt |
| Premier | Custom | Contact sales | SLA, priority support |
Prices as of January 2026. Check sendgrid.com/pricing for current rates.
build Troubleshooting Common Errors
compare SMTP vs SendGrid API
| Feature | SMTP | Web API |
|---|---|---|
| Setup Complexity | Easy - Standard SMTP | Medium - SDK required |
| Speed | Good (~300ms) | Faster (~100ms) |
| Features | Basic + X-SMTPAPI | Full - Templates, batching |
| Legacy Systems | Perfect | May need updates |
| Recommendation | Use SMTP for legacy apps, API for new projects | |
help Frequently Asked Questions
What is the SendGrid SMTP server address?
The SendGrid SMTP server is smtp.sendgrid.net. Use port 587 for TLS (recommended), port 465 for SSL, or port 2525 as an alternative if other ports are blocked.
What username do I use for SendGrid SMTP?
The username for SendGrid SMTP is always the literal string apikey (not your email or account name). Your generated API key is used as the password.
How many emails can I send with SendGrid free tier?
SendGrid's free tier allows 100 emails per day forever. For higher volumes, paid plans start at 40,000 emails/month for $19.95/month (Essentials plan).
Do I need to verify my domain for SendGrid?
Yes, domain authentication is strongly recommended. Without it, emails are sent via sendgrid.net which hurts deliverability. Domain verification requires adding CNAME records to your DNS.
Why is port 587 recommended over 465?
Port 587 with STARTTLS is the modern standard for email submission. Port 465 uses implicit SSL which is technically deprecated (though still supported). Port 587 also tends to have fewer firewall issues.
Managing Multiple SMTP Accounts?
Postigo rotates between your SMTP accounts automatically, handles failures, and maximizes deliverability.