PHPMailer emails not reaching Gmail recipients from custom SMTP server

I’m having trouble with my email delivery setup and need some guidance. I’m using PHPMailer with my hosting provider’s SMTP settings (not Gmail’s SMTP) to send emails from contact forms on my website. The strange thing is that emails reach most recipients just fine, but they never seem to arrive at Gmail addresses.

The main issue: Gmail users aren’t receiving any emails from my forms, and I’m not seeing any obvious error messages in my logs.

What I’m wondering: Is there something specific that Gmail blocks? Are there particular settings or configurations needed to ensure Gmail accepts emails from custom domain SMTP servers?

Here’s my current setup:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require "vendor/phpmailer/src/PHPMailer.php";
require "vendor/phpmailer/src/SMTP.php";
require "vendor/phpmailer/src/Exception.php";

$mailer = new PHPMailer(TRUE);
$mailer->isSMTP();
$mailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mailer->SMTPAuth = true;
$mailer->Host = "smtp.mysite.com";
$mailer->Port = 465;
$mailer->Username = "[email protected]";
$mailer->Password = "mypassword123";
$mailer->setFrom($senderEmail, $senderName);
$mailer->addAddress("[email protected]", "John Doe");
$mailer->addCC($senderEmail, $senderName);
$mailer->addBCC("[email protected]", "Site Admin");
$mailer->Subject = "Contact form submission";
$mailer->Body = $messageContent;
$mailer->send();
$mailer = null;

Any suggestions on what might be causing this Gmail delivery issue?

yeah man, gmail can be real picky! make sure u got ur SPF and DKIM set up right on ur domain. those settings help a lot. also, check if ur smtp server’s got a good rep, some cheap hosts get blacklisted easily!

Gmail’s spam filters are brutal and will block emails from domains that don’t have proper authentication set up. You mentioned SPF and DKIM, but you also need DMARC policy for your domain. I ran into this exact problem last year - Gmail just silently drops emails from servers with bad reputation scores. Use MXToolbox or Google Postmaster Tools to check your domain’s sender reputation. Another thing that trips people up is reverse DNS - make sure your SMTP server’s IP has PTR records pointing back to your domain. Gmail might also be rate limiting you if you’re sending emails too fast. Space out your sends and check your server logs for SMTP response codes that show temporary deferrals.

Gmail’s crazy strict about mail server config, especially for smaller domains. One thing people miss is keeping your FROM addresses consistent. I see you’re using $senderEmail in your setFrom method - if that varies or doesn’t match your domain, Gmail will flag it instantly. I had the exact same problem. Contact forms worked fine for Yahoo and Outlook users, but Gmail recipients got nothing. Turns out my hosting provider’s IP range had terrible reputation because other customers were spamming. Fixed it by switching to a dedicated IP and warming it up slowly with small volumes first. Also check if your hosting provider has email authentication services, or consider moving to something like SendGrid for better Gmail deliverability.