473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
6 2198
>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
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
>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
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
$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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Pierre Jelenc | last post by:
I use mail() for a musician's mailing list script that suddenly started having problems after many months of working flawlessly. The code fragment is: if...
12
by: Chris Dewin | last post by:
Hi. I've been thinking about using smtplib to run a mailing list from my website. s = smtplib.SMTP("server") s.sendmail(fromaddress, toaddresess, msg) I know that in this instance, the...
2
by: TomSoCal | last post by:
I have an Access Database of about 400 records, most records have a character field with an e-mail address for the person in that record. How can I use these addresses to create a group mailing to...
1
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address...
39
by: Viken Karaguesian | last post by:
Hello all, <SIGH> I'm soooooo sick and tired of getting spam e-mails. I'm sure that part of the reson for this is that my e-mail address is publicly available on my website, ready to be picked...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
10
by: Newbie | last post by:
Hi all, I'm looking for a way to send newsletter to my subscribers (1000+ in total). I've managed to do it using .NET system.net.mail.smtpclient's sendAsync. I read the email addresses from a...
4
by: NielsM | last post by:
Hello all, I have a table (tblExport03) with the following fields: ID : autonumber Title : text FirstName : text LastName : text OrganisationName : text BusinessEmailAddres : text (isNull,...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.