Webinoly integrates Postfix SMTP relay to enable reliable email delivery from your server. This is essential for WordPress transactional emails, contact forms, and system notifications.
Prerequisites
SMTP functionality requires:
- Postfix mail server (installed with PHP stack)
- SMTP service credentials (Gmail, SendGrid, Mailgun, etc.)
- A valid domain name configured on your server
Install Postfix
Postfix is included in the full PHP stack:
Or install separately:
Interactive Setup
Configure SMTP with the interactive wizard:
You’ll be prompted for:
- SMTP Host: Your email provider’s SMTP server (e.g.,
smtp.gmail.com)
- User: SMTP username or email address
- Password: SMTP password or app-specific password
- Main Hostname/Domain: Your primary domain for sending emails
Non-Interactive Setup
Provide all credentials in one command:
Format: [host,username,password,hostname]
Webinoly only supports TLS on port 587. Ensure your SMTP provider supports STARTTLS on port 587.
SMTP Provider Examples
Gmail
- Enable 2-factor authentication on your Google account
- Generate an app-specific password: https://myaccount.google.com/apppasswords
- Configure Webinoly:
Gmail has a daily sending limit of 500 emails for free accounts. Consider a dedicated email service for high-volume sending.
SendGrid
- Create a SendGrid account and API key
- Configure:
sudo webinoly -smtp=[smtp.sendgrid.net,apikey,your-api-key,yourdomain.com]
Note: Username is literally “apikey”, password is your API key
Mailgun
- Create Mailgun account and obtain SMTP credentials
- Configure:
sudo webinoly -smtp=[smtp.mailgun.org,[email protected],smtp-password,yourdomain.com]
Amazon SES
- Create SMTP credentials in AWS SES console
- Configure:
sudo webinoly -smtp=[email-smtp.us-east-1.amazonaws.com,AWS-ACCESS-KEY,AWS-SECRET-KEY,yourdomain.com]
Postmark
sudo webinoly -smtp=[smtp.postmarkapp.com,your-server-token,your-server-token,yourdomain.com]
Brevo (Sendinblue)
Configuration Files
SMTP settings are stored in:
Main Config: /etc/postfix/main.cf
myhostname = yourdomain.com
myorigin = /etc/mailname
relayhost = smtp.example.com:587
Credentials: /etc/postfix/sasl_passwd
Hostname: /etc/mailname
The sasl_passwd file contains plaintext passwords and is only readable by root (0600 permissions).
Main Hostname
The main hostname/domain serves as:
- The FROM domain for system emails
- Server’s mail identity
- Default origin for outgoing mail
Requirements:
- Must be a valid domain configured on your server
- Should match a site in
/etc/nginx/sites-available/
- Recommended: Configure SPF and DKIM records for this domain
Test Email Delivery
Verify SMTP is working:
# Send test email
echo "Test email from Webinoly" | mail -s "Test Subject" [email protected]
# Check mail queue
mailq
# View mail log
sudo log -mail
Monitor Email Logs
View email delivery logs:
# Real-time mail logs
sudo log -mail
# Or
sudo log -email
# Check for errors
sudo tail -f /var/log/mail.err
Common log entries:
status=sent - Email sent successfully
status=deferred - Temporary failure, will retry
status=bounced - Permanent failure
WordPress Integration
For better WordPress email management:
- Install WP Mail SMTP plugin
- Configure with “Other SMTP” option:
- SMTP Host:
localhost
- SMTP Port:
25
- Encryption: None
- Authentication: Off
WordPress will use Postfix relay configured by Webinoly.
Alternative: Direct SMTP in WordPress
Configure WordPress to use external SMTP directly:
- Install WP Mail SMTP plugin
- Enter your SMTP provider credentials
- This bypasses Postfix (not recommended - use Webinoly SMTP instead)
Using Webinoly’s SMTP relay centralizes email configuration and simplifies management across multiple WordPress sites.
Troubleshooting
Emails Not Sending
-
Check Postfix status:
sudo systemctl status postfix
-
Test SMTP credentials:
# Test authentication
sudo postfix check
sudo postfix reload
-
Verify SMTP host is reachable:
telnet smtp.example.com 587
-
Check mail queue:
-
View detailed logs:
sudo tail -100 /var/log/mail.log
Authentication Failures
If you see authentication failed errors:
- Verify credentials are correct
- Check if app-specific password is needed (Gmail)
- Ensure SMTP user has sending permissions
- Regenerate SMTP password/API key
DNS/SPF Issues
Emails marked as spam:
-
Add SPF record to main hostname domain:
v=spf1 include:_spf.google.com ~all
(Adjust based on SMTP provider)
-
Configure DKIM if supported by provider
-
Set up DMARC policy:
Firewall Blocking Port 587
If connection times out:
# Check if port 587 is blocked
sudo ufw status
# Allow outgoing SMTP
sudo ufw allow out 587/tcp
Queue Not Processing
Flush stuck mail queue:
# Force queue processing
sudo postqueue -f
# Remove specific messages
sudo postsuper -d MESSAGE_ID
# Remove all queued messages
sudo postsuper -d ALL
Backup SMTP Configuration
SMTP configuration is included in:
Full Server Backup:
sudo webinoly -backup=export -server
This includes Postfix configuration files in /var/www/webinoly_backup_smtp
Manual Backup:
sudo cp /etc/postfix/main.cf /root/main.cf.backup
sudo cp /etc/postfix/sasl_passwd /root/sasl_passwd.backup
sudo cp /etc/mailname /root/mailname.backup
Disable SMTP
Restore default Postfix configuration:
# Restore from template
sudo cp /opt/webinoly/templates/source/main.cf /etc/postfix/main.cf
# Remove credentials
sudo rm /etc/postfix/sasl_passwd*
# Restart Postfix
sudo systemctl restart postfix
Security Best Practices
- Use App-Specific Passwords: Don’t use main account passwords
- Rotate Credentials: Change SMTP passwords regularly
- Monitor Logs: Watch for unauthorized sending attempts
- Rate Limiting: Most providers limit sending rates
- SPF/DKIM/DMARC: Configure email authentication
- Restrict Access: Keep
sasl_passwd file secure (already 0600)
Advanced Configuration
Custom Postfix Settings
Edit main configuration:
sudo nano /etc/postfix/main.cf
Common customizations:
# Set message size limit (50MB)
message_size_limit = 52428800
# Set mailbox size limit
mailbox_size_limit = 0
# Set sender address
smtp_generic_maps = hash:/etc/postfix/generic
Reload after changes:
sudo systemctl reload postfix
Multiple SMTP Relays
For advanced setups with sender-dependent routing:
# Edit sender-dependent relay map
sudo nano /etc/postfix/sender_relay
Add:
Configure in main.cf:
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
Hash and reload:
sudo postmap /etc/postfix/sender_relay
sudo systemctl reload postfix
Advanced Postfix modifications may be overwritten by Webinoly stack resets. Keep backups of custom configurations.