🚀 Rapid Context
So you’ve decided to get civilized and let your WordPress site send emails properly – via SMTP, no less. You installed WP Mail SMTP, pointed it to your mail server, hit “Save”, sent a test… and boom 💥:
“Could not connect to SMTP host. SSL certificate verify failed.”
Why?
Because your Postfix on CentOS 7 setup is stubbornly stuck in the past and doesn’t properly handle multidomain SSL certificates (a.k.a. SAN certs). WordPress, being a responsible adult, sees the mismatch and refuses to play ball. Yes, CentOS 7 and it’s year 2025
⚡ Step 1: Install WP Mail SMTP
This one’s easy:
- Go to your WordPress dashboard
- Navigate to Plugins > Add New
- Search for
WP Mail SMTP
- Click Install Now and then Activate
You’re officially in the game.
✂️ Step 2: Patch functions.php
Like a Barbarian (Temporarily!)
This isn’t elegant. This isn’t scalable. This is duct tape and chewing gum. But it works.
Here’s what to do:
- Go to Appearance > Theme File Editor
- Select your active theme’s
functions.php
- Scroll all the way to the bottom of the file
- Paste the following code right before the closing
?>
PHP tag (if it exists):
add_action( 'phpmailer_init', function( $phpmailer ) {
$phpmailer->Timeout = 80;
});
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
return $phpmailer;
});
This code:
✅ Gives Postfix a bit more breathing room (timeout = 80s)
✅ Skips certificate verification (which is where Postfix+CentOS 7 fails)
✅ Lets you send mail despite SAN mismatches or self-signed certs
😈 The Dirty Truth
Yes, this is a bypass. A shim. A Band-Aid on a bullet wound.
But when you’re dealing with legacy CentOS boxes and a mail server that’s allergic to SANs, you gotta do what you gotta do.
🙏 A Sysadmin’s Prayer
Our Father, who art in
/etc
,
hallowed be thyhostnamectl
. Thyyum
come, thysystemctl
be done,
on CentOS as it is on Alma.
Give us this day our dailydnf
, and forgive us ourSELinux
denials,
as we forgive those who mess with/etc/postfix/main.cf
.
Lead us not into deprecated TLS, but deliver us from SAN errors.
For thine is the uptime, and the patches, and the rolling releases,
forever and ever, until RHEL kills CentOS.
Amen.
🧠 Filed under: WordPress, SMTP, CentOS, quick-fixes, things-you-shouldn’t-do-but-you-do-anyway
🔌 Related tags: #sysadmin #wpMailSMTP #functionsPHP #emailmadness
🧰 Coming soon: “How to write a plugin that doesn’t make future-you cry.”