Forum Moderators: coopster
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?
$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
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?
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.
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.