SMTP Integration Guide
Connect your own SMTP server to send emails directly from Heffl. This guide covers setup, configuration options, troubleshooting, and best practices.Overview
SMTP (Simple Mail Transfer Protocol) integration allows you to send emails using your own email server instead of Heffl’s default email service. This gives you:- Full control over your email sending domain and reputation
- Custom sender addresses using your business domain
- Higher sending limits based on your email provider
- Better deliverability with properly configured SPF/DKIM/DMARC
Prerequisites
Before setting up SMTP integration, you’ll need:- SMTP server credentials from your email provider
- Sender email address that’s authorized to send from your SMTP server
- DNS records configured (SPF, DKIM, DMARC) for optimal deliverability
Configuration Fields
Sender Email
The email address that will appear in the “From” field of sent emails.- Required: Yes
- Example:
[email protected] - Important: This must match your SMTP account or be an authorized alias. Using an unauthorized address may cause emails to be rejected.
From Name
The display name shown to recipients alongside the email address.- Required: No
- Example:
John from Acme Corp - Note: If left empty, recipients will only see the email address.
SMTP Host
Your email provider’s SMTP server address.- Required: Yes
- Examples:
- Gmail:
smtp.gmail.com - Microsoft 365:
smtp.office365.com - Zoho:
smtp.zoho.com - Amazon SES:
email-smtp.us-east-1.amazonaws.com - Custom hosting: Check your hosting provider’s documentation
- Gmail:
Port
The port number used for SMTP connections.- Required: Yes
- Common ports:
Port Encryption Description 587 STARTTLS Recommended. Starts unencrypted, upgrades to TLS 465 SSL/TLS Immediate encryption (implicit TLS) 25 None Unencrypted. Often blocked by ISPs. Avoid if possible
Encryption
The security protocol used to encrypt the connection.- Required: Yes
- Options:
- STARTTLS (Port 587) - Recommended for most providers. Connection starts unencrypted and upgrades to TLS.
- TLS/SSL (Port 465) - For servers requiring immediate encryption from connection start.
- None (Port 25) - No encryption. Only use for internal/legacy servers on trusted networks.
Username
Your SMTP authentication username.- Required: Yes
- Usually: Your full email address
- Note: Some providers use a separate SMTP username. Check your provider’s documentation.
Password
Your SMTP authentication password.- Required: Yes
- Important security notes:
- For Gmail with 2FA enabled: Generate an App Password
- For Microsoft 365 with 2FA: Generate an App Password
- For Zoho: Enable App-Specific Passwords
- Your password is encrypted and stored securely
Validate SSL Certificate
Controls whether the server’s SSL certificate is verified.- Required: No (defaults to disabled)
- Enable when: Using production email servers with valid SSL certificates
- Disable when: Using self-signed certificates (common with private hosting mail servers)
- Security note: Disabling certificate validation makes the connection vulnerable to man-in-the-middle attacks. Only disable for trusted internal servers.
Common Provider Configurations
Gmail / Google Workspace
- Enable “Less secure app access” or use App Passwords
- Google may block connections from new locations initially
Microsoft 365 / Outlook
Zoho Mail
Amazon SES
cPanel / Hosting Providers
Troubleshooting
Connection Timeout
Symptoms: Integration test fails with “Connection timed out” Possible causes:- Wrong host or port - Double-check your provider’s SMTP settings
- Firewall blocking - Your network may block outgoing SMTP ports
- Wrong encryption setting - Try switching between STARTTLS and TLS/SSL
- Server is slow - Some hosting providers have slower mail servers
- Verify host and port are correct
- Try port 587 with STARTTLS first, then 465 with TLS/SSL
- Contact your network administrator about firewall rules
Authentication Failed
Symptoms: Error “Authentication failed” or “535” error code Possible causes:- Wrong username/password - Re-check credentials
- 2FA enabled without app password - Generate an app-specific password
- SMTP access disabled - Enable SMTP in your email provider settings
- Account security block - Provider blocked the connection as suspicious
- For Gmail: Enable 2FA and create an App Password
- For Microsoft 365: Ensure SMTP AUTH is enabled for the account
- Check your email for security alerts from your provider
- Try logging into webmail to unlock the account
Certificate Error
Symptoms: Error mentioning “certificate”, “SSL”, or “TLS” Possible causes:- Self-signed certificate - Server uses a certificate not trusted by default
- Expired certificate - Server’s SSL certificate has expired
- Wrong encryption setting - Mismatch between port and encryption type
- Disable “Validate SSL Certificate” for self-signed certs
- Contact your hosting provider about certificate issues
- Ensure encryption setting matches the port (587=STARTTLS, 465=TLS/SSL)
Emails Going to Spam
Symptoms: Emails delivered but land in recipients’ spam folders This is NOT a code issue - it’s related to email authentication and reputation. Solutions:- Configure SPF record - Add your sending server to your domain’s SPF record
- Set up DKIM - Enable DKIM signing in your email provider
- Configure DMARC - Add a DMARC policy to your DNS
- Use a consistent sender - Don’t change your “From” address frequently
- Warm up your domain - Start with low volumes and gradually increase
- Check blacklists - Verify your sending IP isn’t blacklisted
Connection Refused
Symptoms: Error “ECONNREFUSED” Possible causes:- Wrong port - Server doesn’t accept connections on that port
- Server down - SMTP server is temporarily unavailable
- IP blocked - Your IP may be blocked by the server
- Try different ports (587, 465, 25)
- Contact your email provider to verify server status
- Check if your IP needs to be whitelisted
Best Practices
Security
- Use encryption - Always use STARTTLS or TLS/SSL. Avoid unencrypted connections.
- Use app passwords - Don’t use your main account password when app passwords are available.
- Enable certificate validation - Only disable for known self-signed certificates.
- Rotate credentials - Periodically update your SMTP password.
Deliverability
- Set up email authentication - Configure SPF, DKIM, and DMARC for your domain.
- Use a consistent sender address - Stick to one or few sender addresses.
- Monitor bounce rates - High bounce rates hurt your reputation.
- Don’t send spam - Only send to recipients who’ve opted in.
Performance
- Use a reliable provider - Enterprise email providers offer better uptime.
- Monitor sending limits - Don’t exceed your provider’s rate limits.
- Handle failures gracefully - Implement retry logic for temporary failures.
Email Authentication (DNS Records)
For optimal deliverability, configure these DNS records:SPF (Sender Policy Framework)
Tells receiving servers which servers can send email for your domain.DKIM (DomainKeys Identified Mail)
Adds a digital signature to verify emails weren’t tampered with.- Usually configured in your email provider’s admin panel
- Provider generates a DNS record to add to your domain
DMARC (Domain-based Message Authentication)
Tells receiving servers what to do with emails that fail SPF/DKIM checks.Testing Your Configuration
After setting up SMTP integration:- Connection test - Heffl tests the connection when you save the integration
- Send a test email - Send an email to yourself to verify delivery
- Check spam folder - Ensure emails don’t land in spam
- Test from different clients - Verify emails look correct in various email clients
- Check email headers - Verify SPF/DKIM/DMARC pass in email headers
Frequently Asked Questions
Can I use Gmail’s SMTP for free?
Yes, but with limitations:- Free Gmail: ~500 emails/day
- Google Workspace: ~2,000 emails/day
- Requires App Password if 2FA is enabled
Why do I need an App Password?
If you have 2-Factor Authentication enabled (which you should), your regular password won’t work for SMTP. App Passwords are special passwords generated for specific applications that bypass 2FA.Can I send from any email address?
No. You can only send from:- The email address associated with your SMTP account
- Aliases configured in your email provider
- Verified sender addresses (for services like Amazon SES)
What happens if SMTP connection fails?
Heffl queues emails and retries failed sends. If the SMTP server is temporarily unavailable, emails will be sent once the connection is restored.How many emails can I send?
This depends on your email provider’s limits:- Gmail: 500/day (free) or 2,000/day (Workspace)
- Microsoft 365: 10,000/day
- Amazon SES: Based on your account tier
- Custom hosting: Check with your provider