Why Aren’t My Emails Reaching My Zoho Address Using PHP’s mail() Function?

0
5
Asked By CuriousCoder92 On

I've got a PHP script on my site that's sending emails using the basic mail() function, and while it works fine for my Gmail and Outlook addresses, my Zoho-hosted email is just not receiving them at all—not even in the spam folder. The sender's address is [email protected] from my Bluehost-hosted subdomain. I'm curious if Zoho has any specific requirements that I'm missing out on. Here's the PHP code I'm using:

```php
<?php
// Send email using raw PHP mail()
function send_email_test() {
$to = '[email protected]'; // My Zoho address
$subject = 'Email Test v2';
$message = '

v2 This is a test email

The email system is working properly.

Time: ' . date('Y-m-d H:i:s') . '

';

$headers = "MIME-Version: 1.0" . "rn";
$headers .= "Content-type: text/html; charset=UTF-8" . "rn";
$headers .= "From: [email protected]" . "rn";
$headers .= "Reply-To: [email protected]" . "rn";
$headers .= "X-Mailer: PHP/" . phpversion();

if (mail($to, $subject, $message, $headers)) {
echo "Mail sent successfully.";
} else {
echo "Mail failed to send.";
}
}
send_email_test();
?>
```

Could anyone explain why my emails aren't getting to my Zoho inbox? Thanks a bunch!

3 Answers

Answered By WebWizard76 On

Make sure to check the mail routing settings in your hosting cPanel. I had a similar issue with my emails not being delivered, and it turned out I needed to set the Email Routing to 'Remote Mail Exchanger' instead of 'Auto'. This tweak worked for me!

CuriousCoder92 -

Thanks for the tip! I hadn’t thought about that setting. I’ll check my cPanel.

Answered By TechFinder99 On

Definitely check your server’s mail logs located at `/var/mail.log` or something similar on your web server. There might be messages about why Zoho is not accepting your emails. If they're dropping the connection or filtering them out, the logs will help you figure that out.

Answered By EmailGuru77 On

PHP's mail() function can be pretty hit or miss, especially when it's not routed through SMTP. This can affect deliverability, as providers like Zoho may have stricter filtering. You might want to look into using an email sending service like SendGrid that will improve your chances of getting into inboxes instead of spam. They handle a lot of the backend issues for you, making it easier to ensure deliverability.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.