By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Mail() - arriving at some addresses, never at others

P: n/a
Hi folks,

HELP!!!!

My habitual use of mail() is causing me some grief. I am having
slightly different results depending on the server I use but the gist
is that mail() is returning 1, and I can send mail to yahoo.com,
gmail.com, and hotmail.com no problem. 100% success.

Same script from some servers gets mail through to cox.net addresses,
my ISP.

However, my own domain, nolaflash.com is not receiving these mails at
all, nor are several other domains on shared hosting servers.
NolaFlash.com and Artifexdev.com for two examples.

I have tried running the scripts on three different servers with the
only difference that the Cox address works on one AND if I host the
script on NolaFlash then the mail to NolaFlash addresses gets through.

Here are four ways I have tried this:

// NO HEADERS
$to = 's******@gmail.com';
$subject = "Inquiry from some.com";
$msg = 'whatever';
$result = mail($to, $subject, $msg);

// FULL HEADERS
$to = 's******@gmail.com';
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
$headers = "From: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Message-ID: <" . date("YdmHis") .
".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
$result = mail($to, $subject, $msg, $headers);

// FULL HEADERS PLUS -f FLAG to set the envelope sender address
$to = 's******@gmail.com';
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
$headers = "From: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Message-ID: <" . date("YdmHis") .
".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
$result = mail($to, $subject, $msg, $headers,
'-**********@mysite.com');
I have also played around with setting all the headers to good
addresses at my site to see any bounces from the SMTP server.

Any advice greatly appreciated!!!

jg

Jun 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
>My habitual use of mail() is causing me some grief. I am having
slightly different results depending on the server I use but the gist
is that mail() is returning 1, and I can send mail to yahoo.com,
gmail.com, and hotmail.com no problem. 100% success.
Directly putting values from $_POST[] into email headers without
checking them for the absence of carriage return or linefeed
characters WILL get you listed as a spammer because your page WILL
be abused by spammers. (applies to your FULL HEADERS, FULL HEADERS
PLUS, and I don't see the 4th way). If you see carriage returns
or linefields in any fields to be put in headers, you should not
send mail and tell the spammer to fuck off (but don't be so polite
about it).

You can expect that some servers will reject your message as SPAM
because:
- There is no From: line.
- The address on the From: line is invalid.
- The address on the From: line is not allowed to send mail from
anyplace but specific servers (SPF) and the recipient server is
enforcing it.
- You aren't on their whitelist.
- Some spammer abused a script on another site hosted by the same
web provider as you did 6 years ago, and you have the same IP address.

Gordon L. Burditt
Here are four ways I have tried this:

// NO HEADERS
$to = 's******@gmail.com';
$subject = "Inquiry from some.com";
$msg = 'whatever';
$result = mail($to, $subject, $msg);

// FULL HEADERS
$to = 's******@gmail.com';
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
$headers = "From: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Message-ID: <" . date("YdmHis") .
".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
$result = mail($to, $subject, $msg, $headers);

// FULL HEADERS PLUS -f FLAG to set the envelope sender address
$to = 's******@gmail.com';
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
$headers = "From: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Message-ID: <" . date("YdmHis") .
".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
$result = mail($to, $subject, $msg, $headers,
'-**********@mysite.com');
I have also played around with setting all the headers to good
addresses at my site to see any bounces from the SMTP server.

Jun 16 '06 #2

P: n/a
Gordon,

Thank you for the reply. Your advice is sound practice but in my
opinion it doesn't address my difficulty.

The mail which fails to arrive is being sent under controlled
circumstances and with the exception of the No Headers version all
attempts have included a From: header. And, for this controlled
testing, I do know that there are no carriage returns in the values.

The emails were generated on four seperate severs not owned by the same
parent and hence IP blocks differed. The results however remained the
same even when hard coded values were used in the headers. Each server
could get it through to Gmail et al but none were getting it through to
the vhosted accounts. If it was an IP based block it certainly is very
broad.

Anyway, thanks for considering my problem!

jg

Additionally the address which the
Gordon Burditt wrote:
My habitual use of mail() is causing me some grief. I am having
slightly different results depending on the server I use but the gist
is that mail() is returning 1, and I can send mail to yahoo.com,
gmail.com, and hotmail.com no problem. 100% success.


Directly putting values from $_POST[] into email headers without
checking them for the absence of carriage return or linefeed
characters WILL get you listed as a spammer because your page WILL
be abused by spammers. (applies to your FULL HEADERS, FULL HEADERS
PLUS, and I don't see the 4th way). If you see carriage returns
or linefields in any fields to be put in headers, you should not
send mail and tell the spammer to fuck off (but don't be so polite
about it).

You can expect that some servers will reject your message as SPAM
because:
- There is no From: line.
- The address on the From: line is invalid.
- The address on the From: line is not allowed to send mail from
anyplace but specific servers (SPF) and the recipient server is
enforcing it.
- You aren't on their whitelist.
- Some spammer abused a script on another site hosted by the same
web provider as you did 6 years ago, and you have the same IP address.

Gordon L. Burditt
Here are four ways I have tried this:

// NO HEADERS
$to = 's******@gmail.com';
$subject = "Inquiry from some.com";
$msg = 'whatever';
$result = mail($to, $subject, $msg);

// FULL HEADERS
$to = 's******@gmail.com';
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
$headers = "From: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Message-ID: <" . date("YdmHis") .
".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
$result = mail($to, $subject, $msg, $headers);

// FULL HEADERS PLUS -f FLAG to set the envelope sender address
$to = 's******@gmail.com';
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
$headers = "From: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
$headers .= "Message-ID: <" . date("YdmHis") .
".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
$result = mail($to, $subject, $msg, $headers,
'-**********@mysite.com');
I have also played around with setting all the headers to good
addresses at my site to see any bounces from the SMTP server.


Jun 16 '06 #3

P: n/a
>Thank you for the reply. Your advice is sound practice but in my
opinion it doesn't address my difficulty.

The mail which fails to arrive is being sent under controlled
circumstances and with the exception of the No Headers version all
attempts have included a From: header.
If you send mail from PHP to the email address in the From: header,
is it *ACTUALLY DELIVERED*? Yes, the left hand side really counts.

If the domain in the From: line publishes an SPF record, is the
web site you're running PHP on listed in it?

Does the web site you're running PHP on have valid reverse DNS?
Some mail servers won't accept mail from servers with no reverse DNS.

Can you send email to a server you rent space on, have it fail,
and get the ISP to tell you WHY it failed? Or look at the server
logs yourself?

And, for this controlled
testing, I do know that there are no carriage returns in the values.
Don't put it in production like that. Spammers will abuse it.
But it shouldn't matter for your mail delivery problem.
The emails were generated on four seperate severs not owned by the same
parent and hence IP blocks differed. The results however remained the
same even when hard coded values were used in the headers. Each server
could get it through to Gmail et al but none were getting it through to
the vhosted accounts. If it was an IP based block it certainly is very
broad.


Gordon L. Burditt
Jun 16 '06 #4

P: n/a
Hi Gordon,

Thanks for the continued help!

AFAIK I have only used valid deliverable addresses as the FROM:. I
have been using my own addresses. I will definitely bear in mind that
it must be valid in future I had not been aware of that.

As for your other questions, I will pursue answers to those as well,
though I will probably get the admin to set up a mail account for the
script to use and switch to using Perl's Mail:Sender module under AUTH.
If problems persist then we can be pretty sure we have a blacklisting
issue I think.

Strange that in six years of using this method I have never been so
stymied by it before.

Anyway, I really do appreciate your time and advice!!

Peace,

jg

Gordon Burditt wrote:
Thank you for the reply. Your advice is sound practice but in my
opinion it doesn't address my difficulty.

The mail which fails to arrive is being sent under controlled
circumstances and with the exception of the No Headers version all
attempts have included a From: header.


If you send mail from PHP to the email address in the From: header,
is it *ACTUALLY DELIVERED*? Yes, the left hand side really counts.

If the domain in the From: line publishes an SPF record, is the
web site you're running PHP on listed in it?

Does the web site you're running PHP on have valid reverse DNS?
Some mail servers won't accept mail from servers with no reverse DNS.

Can you send email to a server you rent space on, have it fail,
and get the ISP to tell you WHY it failed? Or look at the server
logs yourself?

And, for this controlled
testing, I do know that there are no carriage returns in the values.


Don't put it in production like that. Spammers will abuse it.
But it shouldn't matter for your mail delivery problem.
The emails were generated on four seperate severs not owned by the same
parent and hence IP blocks differed. The results however remained the
same even when hard coded values were used in the headers. Each server
could get it through to Gmail et al but none were getting it through to
the vhosted accounts. If it was an IP based block it certainly is very
broad.


Gordon L. Burditt


Jun 17 '06 #5

P: n/a
$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";

This is just a suggestion -

Try sending your test emails with the suject "test"

I have noticed some anti-virus-spam traps are now looking at the subject
line for things like ".com" and rejecting them as if they were looking at
executable files. (.com is a valid windows executable extension)

Also be careful what you put in those variables.

tony

ps... should "Inquiry" be "Enquiry" ?
Jun 17 '06 #6

P: n/a
jerrygarciuh wrote:
Hi folks,

HELP!!!!

My habitual use of mail() is causing me some grief. I am having
slightly different results depending on the server I use but the gist
is that mail() is returning 1, and I can send mail to yahoo.com,
gmail.com, and hotmail.com no problem. 100% success. <snip> I have also played around with setting all the headers to good
addresses at my site to see any bounces from the SMTP server.


IIRC, there was/is some problem with mail() function and when the
receiving server is too sensitive, it will throw syntax error and the
e-mail will get bounced (eg. Yahoo). But, since you're saying that you
could send to yahoo.com, it is better that you check for any bounced
mails and reasons.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jun 18 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.