Prerequisites
Before you begin, make sure you have: You’ll also need:- PHP 8.0+ installed
- Composer for package management (or manual installation)
Installation
Install PHPMailer via Composer:Basic Configuration
Here’s a complete example showing how to send an email through Lettr with PHPMailer:Adding Attachments
Attach files to your emails usingaddAttachment():
Adding CC and BCC
Send copies to multiple recipients:Custom Headers
Add custom headers for tracking or additional metadata:WordPress Integration
If you’re using PHPMailer in WordPress, hook intophpmailer_init:
functions.php or a custom plugin.
Troubleshooting
SMTP Error: Could not authenticate
SMTP Error: Could not authenticate
Check your API key is correct and starts with
lttr_. Verify the username is exactly lettr (lowercase). Ensure your API key hasn’t been revoked in the dashboard.SMTP Error: Could not connect to SMTP host
SMTP Error: Could not connect to SMTP host
Your firewall may be blocking outbound SMTP connections on port 587. Try alternate ports (
465, 2465, or 2587). Verify smtp.lettr.com resolves correctly: nslookup smtp.lettr.com.Invalid address error
Invalid address error
Check that all email addresses are properly formatted. Ensure the “from” address uses a verified sending domain.
Could not access file (attachments)
Could not access file (attachments)
Verify attachment file paths are correct and the PHP process has read permissions. Check that files exist using
file_exists() before attaching.Enable debug output
Enable debug output
Enable SMTP debugging during development:Debug levels:
SMTP::DEBUG_OFF(0) — No output (production)SMTP::DEBUG_CLIENT(1) — Client messagesSMTP::DEBUG_SERVER(2) — Client and server messages (recommended)SMTP::DEBUG_CONNECTION(3) — Connection status + messagesSMTP::DEBUG_LOWLEVEL(4) — Low-level data output
Using port 465 instead of 587
Using port 465 instead of 587
If you prefer port 465 with implicit SSL/TLS:Both ports are equally secure. Port 465 establishes an encrypted connection immediately, while port 587 upgrades via STARTTLS.