magenta
magenta

Reputation:

PHP mail not showing up at Gmail but shows up at Hotmail and other 3rd party/ISP account

I have 2 sites where mail is sent to two vanity gmail accounts. I'm using PHP to handle the mail, but the mail is not showing up at gmail (not in spam/junk, it just doesn't show up). If I switch the PHP to send to my personal hotmail account, the mail shows up. Same for a personal email account through my ISP.

The mail used to show up at those 2 vanity gmail accounts, any ideas why they would just stop?

Upvotes: 8

Views: 18456

Answers (5)

Rick2047
Rick2047

Reputation: 1595

I see it is too late but ... following code is working for gmail.

<html>
Mail Responder:<br><br>
<?php 
$to = $_REQUEST['MyEmail'] ; 
$subject = $_REQUEST['subject'] ; 
$greeting = $_REQUEST['greeting'] ; 
$realname = $_REQUEST['realname'] ;
$HisEmail = $_REQUEST['HisEmail'] ; 
$message = $_REQUEST['message'] ;
$headers = 'From: '.$HisEmail;  
//$headers = 'From: $HisEmail' . "\r\n" .
//'Reply-To: [email protected]';

$send = mail($to, $subject, $greeting."\n"."\n".$realname."\n"."\n".$HisEmail."\n"."\n".$message, $headers );
if ($send)
$mailReturns = "Mail sent successfully.";
else
$mailReturns = "Mail sent failed.";

?>
<?php echo $mailReturns; ?>
</html>

Upvotes: 0

acrosman
acrosman

Reputation: 12900

Seems more likely that this is a server configuration issue and not a PHP issue.

As a side note I've found gmail more tolerant than our local system, so I've been able to get messages out to my gmail account, but not my account on the hosting domain.

I don't think Google uses third-party black lists, but they do care about server configuration (does it identify itself correctly, have matching SPF and RDNS records, respond to commands properly). You might try a couple of testing services like this or this.

Upvotes: 0

Evert
Evert

Reputation: 99861

I've found having a proper SPF record for your domain really helps

http://www.openspf.org/SPF_Record_Syntax

Upvotes: 2

WerkkreW
WerkkreW

Reputation: 364

I have encountered problems in the past where certain free email providers would not receive any email from my servers.

I found that a few things can be the culprit, on top of putting the correct headers in the actual message:

  • Make sure your server is configured for reverse dns lookup
  • Make sure you are not running an open smtp relay
  • Make sure your server did not wind up in any email blacklists (if you had an open relay, you probably got blacklisted.

Chances are, PHP is sending the email just fine, but the Google servers are rejecting any messages coming from your server.

You can test this by doing a quick:

mail -s Test [email protected] < /dev/null

If your server is okay, you will receive a message in your gmail, if you don't, PHP isn't the problem.

Upvotes: 4

Thinker
Thinker

Reputation: 14474

There is a possibility you did not set proper header data, and those emails are blocked even before reaching spam folder.

Try adding something like this:

$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]';

This is the fourth parameter of mail() function.

Upvotes: 8

Related Questions