Forum Moderators: coopster

Message Too Old, No Replies

mail() not getting to gmail or yahoo

Tried every trick I could find... at my wits end.

         

Duskrider

2:22 am on May 17, 2007 (gmt 0)

10+ Year Member



Ok, the site I'm working on has the need to send out e-mails to its users (account creation, modification, etc). I've just been using the mail() function to do this with no problems... until I tested the functionality with my gmail account. No dice. I did some reading and found that others who were having the gmail problem also could not get emails to yahoo, so I got an account there and tried it... also no dice.

I've been all over the net trying different header tricks, I've checked my server info at dnsreport (found a NS problem but it has been corrected), I can verify the header information looks correct through my pop mail program, I don't get a single error when the script runs... it just... doesn't work.

I have another domain on the exact same box that sends a notification to my gmail account every night via a cron job script that I got over a year and a half ago. That notification works just fine, so I know that it isn't a server setting or something else I don't have control over. I've looked through the code for that script and can't made heads or tails of it to be honest... it does a bunch of crazy header stuff with boundary strings and base64 encoding because its job is to send a backup file.

The real kicker is that my friend who also has a gmail account received a notice from the script about two weeks ago when he tested it for me. I had a relative test it about a week ago and of the 4 or so e-mails they should've gotten from the script, they got 2. They have a Yahoo account.

In my own testing, nothing is getting through. My host did just recently move me to a new box... I guess that might have something to do with it, but it doesn't make sense that it would work for one of my domains and not the other.

Anyway, here's the code I'm using:

$from = "notification@example.com";
$reply = $from;
$to = 'me@gmail.com';
$body = 'whatever';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-2\nContent-Transfer-Encoding:" .
" 8bit\nX-Priority: 3\nX-MSMail-Priority: Normal\n";

$headers .= "From: $from\n" . "Reply-To: $reply\n" .
"X-Mailer: PHP/" . phpversion() .
"\nX-originating-IP: " . $_SERVER['REMOTE_ADDR'] . "\n";

if (!mail($to, $subject, $body, $headers,"-f $from"))
{
//Do stuff
}

All the headers are from scripts I've seen on the net... before that I was just using "From: notification@example.com" as the only header information sent. The original header definition had /r and /n at the end of each line, but I saw a post somewhere that recommended to take the /r off for gmail so I did. Doesn't seem to hurt other mail programs so far, so I just left it when it didn't work for gmail.

The more I think about it the more I think it might have to do with my recent move to a new server. I don't know what would cause one domain to send mail ok while the other one doesn't. I could understand if it couldn't send any mail, but it's strange how it's just gmail and yahoo and just on that one account.

Any thoughts?

bsterz

2:34 am on May 17, 2007 (gmt 0)

10+ Year Member



Do you have access to the shell? Can you send mail from the command line?

If you have access to the command line try:

ls ¦ mail <youraddress>@gmail.com

This will send a file listing to that email address

jatar_k

2:38 am on May 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



take a look at these

$headers = '';
$sourceemail = 'me@gmail.com';
$myname = 'That guy there';
$headers .= "From: " . $myname . " <" . $sourceemail . ">\r\n";
$headers .= 'Subject: ' . $subject . "\r\n";
$headers .= "Return-Path: " . $sourceemail . "\r\n";
$headers .= "Reply-To: " . $sourceemail . "\r\n";
$headers .= "Content-type: text;\r\n";
$headers .= "Mime-Version: 1.0\r\n";

adding return path may help, order is fairly important, the above uses /r/n instead of just /n, as you tried, may not make a difference at all.

content is also very important, I always used the spamassassin list of tests to help me understand where content issues may arise

[spamassassin.apache.org...]

though you would think if other tests worked then this may not be the problem.

not really sure, headers, content and mail servers is the thing. Are you absolutely sure it is getting sent?

Duskrider

4:05 am on May 17, 2007 (gmt 0)

10+ Year Member



Thanks for the help guys, but still no dice.

I tried the new header information both with and without the "\r" and it didn't make any difference. Unfortunately I'm on a shared box with my host and don't have access to the shell.

I just checked the return address to that email (which I had never intended on making a real address, but did out of frustration thinking that might be the problem) and I get an error message with this in it:

The following address(es) failed:

myfriend@gmail.com
unrouteable mail domain "gmail.com"

And then it spouts out the headers and message that couldn't be sent. I also got one for the yahoo address listing yahoo.com as the mail domain.

Argh.

IndiaMaster

9:31 am on May 22, 2007 (gmt 0)

10+ Year Member



I have also got the same problem. Still searching for a suitable solution.

barns101

12:55 pm on May 22, 2007 (gmt 0)

10+ Year Member



I had a problem with an unroutable mail domain error. It turned out that my host had set a maximum limit to the number of emails sent from each user per hour. It doesn't sound like it'll be the same case here, but I thought that I'd let you know just in case.

Romeo

1:07 pm on May 22, 2007 (gmt 0)

10+ Year Member



and I get an error message with this in it:
The following address(es) failed:
myfriend@gmail.com
unrouteable mail domain "gmail.com"

Perhaps it could be worth to look closer on who exactly is sending this error -- your own server -- another gateway on your provider's end -- a server instance within the target site "gmail.com"?

That information may help you to narrow that down.

Kind regards,
R.

Duskrider

8:48 pm on May 22, 2007 (gmt 0)

10+ Year Member



Just thought I'd let everyone know that I got this problem sorted. It took a ticket to my host, and apparently they had to change some server settings. Once they did... whatever it was they did, emails to Yahoo and Gmail started working normally again.