Overview
Centmin Mod is a LEMP web stack (Linux, Nginx, MariaDB, PHP-FPM) and does not include a full mail server by default. However, your server may still need to send outgoing emails for tasks such as PHP application notifications, cron job alerts, system monitoring, or contact form submissions.
There are two common approaches for handling email on a Centmin Mod server:
- Local MTA (Sendmail/Postfix) — Install a local mail transfer agent for sending outgoing mail directly from the server.
- Third-party transactional email service — Use services like SendGrid, Mailgun, or Amazon SES for reliable email delivery with better deliverability rates.
For @yourdomain.com email hosting (receiving mail), it is recommended to use a dedicated third-party email hosting provider such as Google Workspace, Zoho Mail, or FastMail rather than hosting email on your web server. This provides better reliability, portability when migrating servers, and reduced local resource usage.
Sendmail Installation
Centmin Mod can be configured to install Sendmail during the initial setup or it can be installed manually via YUM/DNF package manager.
To install Sendmail via the Centmin Mod menu:
centmin
# Select option 13 to install Sendmail
Alternatively, if you prefer Postfix as your MTA, you can install it manually:
yum -y install postfix
systemctl enable postfix
systemctl start postfix
Important: Many cloud providers (AWS, Google Cloud, Azure) block outbound SMTP port 25 by default. You may need to request port 25 access or use a relay service on an alternative port (587 or 465). Using a transactional email service is often the most reliable approach.
DNS Records
Proper DNS records are essential for email deliverability. Without them, emails sent from your server are likely to be flagged as spam or rejected entirely. The three key DNS record types for email authentication are SPF, DKIM, and DMARC.
SPF (Sender Policy Framework)
SPF records specify which mail servers are authorized to send email on behalf of your domain. Add a TXT record to your domain's DNS:
SPF DNS Record Example:
Type: TXT Host: @ Value: v=spf1 ip4:YOUR_SERVER_IP -all
Replace YOUR_SERVER_IP with your server's public IP address. The -all flag means only the specified IP is authorized (strict mode). Use ~all for soft fail during testing.
SPF with third-party email services:
# SendGrid v=spf1 ip4:YOUR_SERVER_IP include:sendgrid.net -all # Mailgun v=spf1 ip4:YOUR_SERVER_IP include:mailgun.org -all # Amazon SES v=spf1 ip4:YOUR_SERVER_IP include:amazonses.com -all
DKIM (DomainKeys Identified Mail)
DKIM adds a digital signature to outgoing emails, allowing the recipient's mail server to verify that the email was legitimately sent and has not been tampered with. DKIM uses a public/private key pair:
- The private key is stored on your mail server and used to sign outgoing messages.
- The public key is published as a DNS TXT record so recipients can verify the signature.
DKIM DNS Record Format:
Type: TXT Host: selector._domainkey.yourdomain.com Value: v=DKIM1; k=rsa; p=YOUR_PUBLIC_KEY
The selector is a label you choose (e.g., mail or default). Third-party services typically provide the DKIM record values for you.
DMARC (Domain-based Message Authentication)
DMARC builds on SPF and DKIM to tell receiving mail servers what to do when authentication checks fail. It also provides reporting so you can monitor email authentication results.
DMARC DNS Record Example:
Type: TXT Host: _dmarc.yourdomain.com Value: v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com; pct=100
Policy options: p=none (monitoring only), p=quarantine (mark as spam), p=reject (block entirely). Start with none and tighten after reviewing reports.
Reverse DNS (PTR Record)
A PTR record maps your server's IP address back to your domain name. Many mail servers check for a valid reverse DNS entry and will reject mail from IPs without one. PTR records are typically configured through your VPS or hosting provider's control panel, not your DNS provider.
Testing Email
After installing Sendmail or Postfix and configuring your DNS records, test that your server can send email correctly.
Command Line Test
Send a test email from the command line:
echo "Test email body" | mail -s "Test Subject" you@example.com
PHP mail() Function Test
Create a temporary PHP script to verify that mail() works from your web applications:
<?php
$to = 'you@example.com';
$subject = 'PHP Mail Test';
$message = 'This is a test email sent from PHP mail().';
$headers = 'From: webmaster@yourdomain.com' . "\r\n" .
'Reply-To: webmaster@yourdomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
echo 'Email sent successfully.';
} else {
echo 'Email sending failed.';
}
?>
Security reminder: Remove any test PHP mail scripts from your web root after testing. Leaving them accessible could allow unauthorized use of your server to send spam.
Check Mail Logs
Monitor the mail log to verify emails are being sent and to diagnose delivery issues. See the configuration files page for log file locations.
# View mail log (CentOS/RHEL/AlmaLinux/Rocky Linux)
tail -f /var/log/maillog
# Check mail queue
mailq
Transactional Email Services
For production websites, using a dedicated transactional email service is strongly recommended over local Sendmail/Postfix. These services provide better deliverability, reputation management, analytics, and compliance with email regulations.
SendGrid
Industry-leading email delivery platform with SMTP relay and REST API. Free tier includes 100 emails/day.
sendgrid.comMailgun
Developer-friendly email API with powerful routing and validation features. Free trial with 5,000 emails for 3 months.
mailgun.comAmazon SES
Cost-effective email service integrated with AWS. Pay per email with no monthly minimum — ideal for high-volume senders.
aws.amazon.com/sesPostmark
Focused exclusively on transactional email with industry-best delivery speed. Free tier with 100 emails/month.
postmarkapp.comMost services can be configured as an SMTP relay in your Postfix or Sendmail configuration, or used directly via their API from your PHP applications using libraries like PHPMailer or SwiftMailer.
# Example: SendGrid SMTP relay via Postfix
relayhost = [smtp.sendgrid.net]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000
@yourdomain.com Email Hosting
For receiving email at your domain (e.g., info@yourdomain.com), it is strongly recommended to use a third-party email hosting provider rather than running a mail server on your web server. Benefits include:
- Portability — Your email is uninterrupted when migrating between VPS or dedicated servers.
- Reduced resource usage — Less disk and CPU consumption on your web server.
- Reliability — Dedicated mail infrastructure with redundancy and spam filtering.
- Security — Particularly important for domains using HTTPS SSL certificates that require domain-validated email verification.
Recommended Providers
| Provider | Starting Price | Notes |
|---|---|---|
| Google Workspace | $7.20/user/month | Gmail interface, 30GB+ storage, integrated with Google apps |
| Zoho Mail | Free (up to 5 users) | Free tier with 5GB/user, iOS and Android apps available |
| FastMail | $5/user/month | Custom domain support, 30GB storage, privacy-focused |
| Rackspace Email | $2.99/mailbox/month | 25GB storage, free 14-day trial, migration services |
| Microsoft 365 | $6/user/month | Outlook/Exchange, 50GB mailbox, includes Office apps |
Troubleshooting
Common email delivery issues and their solutions:
Emails going to spam
- Verify SPF, DKIM, and DMARC records are correctly configured
- Ensure your server IP is not on any email blacklists (check at MXToolbox)
- Set up a valid PTR (reverse DNS) record for your server IP
- Use a consistent "From" address that matches your domain
PHP mail() returns false
- Verify Sendmail or Postfix is installed and running:
systemctl status sendmailorsystemctl status postfix - Check PHP's
sendmail_pathin php.ini:php -i | grep sendmail_path - Review
/var/log/maillogfor error messages
Connection timeout on port 25
- Cloud providers often block port 25 — contact your provider to request access or use port 587/465
- Check if CSF Firewall is blocking outbound SMTP
- Consider using an SMTP relay service on port 587 (submission) instead
Emails not being received
- Check the mail queue with
mailqfor stuck messages - Verify DNS records with
dig yourdomain.com TXT - Test deliverability at mail-tester.com