mail not being received by yahoo mail

5 views
Skip to first unread message

henson

unread,
May 19, 2009, 1:54:48 AM5/19/09
to NZ PHP Users Group
Hi All,

I'm having this problem with sending HTML mail to my yahoo.com email.
When I send mail to my yahoo.com mail, somehow, I don't receive it but
if I send it to my other email like m...@myemail.com, I can read it in
my webmail. I have been trying different combinations in my header
but still haven't gotten a solution.

Below is the test code I used:

// recipient
$to = 'send2...@yahoo.com' ;

// subject
$subject = 'Test HTML page sent by PHP mail function';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Henson <send2...@yahoo.com>' . "\r\n";
$headers .= 'From: TestMailer <birt...@example.com>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);


Thanks in advance

chris burgess

unread,
May 19, 2009, 4:35:08 AM5/19/09
to nzp...@googlegroups.com
If you're sending from an SMTP server on a home user or dynamic IP, you may need to use your ISPs SMTP server instead. Many (most?) NZ ISPs intentionally list their broadband IPs in the RBLs to avoid spam being sent from botnet machines on their networks.

If you are sending from such an IP, your emails will be affected. Look into smarthosting or configuring PHP to send via your ISPs SMTP server.

The other likely reason is that Yahoo! have decided your (non-dynamic) originating IP is spammy and are either routing you to the spam folder by default or simply deferring your mails. If that's the case, you'll need to find out why they think it's spammy. Is it a shared server being abused by another customer? Is your webserver relaying email it shouldn't?

Either way, I think the next step for you to debug is to watch your mailserver logs to see what Yahoo!'s SMTP server is saying when asked to receive your email.

Yahoo! have a low tolerance of suspected spam - OTOH, in my experience they respond quickly to reports of false positives too, provided you follow their set procedures.

Yahoo! handle Xtra's mail, so the net results of being flagged as spam by Yahoo! are particularly bad in NZ where Xtra handle a lot of home user emails.

Good luck!

Craig Anderson

unread,
May 19, 2009, 5:43:46 AM5/19/09
to nzp...@googlegroups.com
Hi.
PHP's mail() function often doesn't work very well. One of the main
problems is that mail typically has an envelope sender of the username
of your account on your web server. This can be bad for many reasons,
one of which being that there may be no MX records for that particular
host, but there are plenty of other potential problems caused by this.

The From: address that you specify in PHP's mail() is the from address
that appears in the mail's headers, but it's not the only from address
in an email message. The other one is the envelope sender address
specified within the SMTP communication itself which can be
different. And with php mail() will almost certainly be different.

If you're on a Windows server, then one solution is to simply to add
something like:
ini_set('sendmail_from', 'birt...@example.com');
before the call to mail() or to otherwise configure php.ini with the
same. This sets the envelope sender.

On some linux/*ix servers you can simply add an additional argument to
PHP mail() to specify options to sendmail to set the envelope sender,
for example:
mail($to, $subject, $message, $headers, "-f birt...@wxample.com");
however, overriding the envelope sender in this way requires
permission that won't necessarily have.

The most generic option (and therefore recommended way) is to use
something like Zend_Mail and use SMTP transport. There are many PHP
SMTP mail options out there, find one that best suits your
environment. Most of them will make it much easier to send attachments
too. You generally don't have to worry about the envelope sender at
all when using these packages.

If you're stuck, i have a php mail() replacement around that uses SMTP
and works exactly like PHP mail().
-Craig

Jayakrushna Pattanaik

unread,
May 19, 2009, 8:17:17 AM5/19/09
to nzp...@googlegroups.com
Plz somebody send me a price quote form, with form processing code in PHP.
Thank u
 Jay

Craig Anderson

unread,
May 19, 2009, 2:44:41 PM5/19/09
to nzp...@googlegroups.com
Hi.
Oh yes, one other thing. You should include an RFC822 date in the
headers. So add something like:
$mdate = gmdate("r", time());
$headers .= "Date: $mdate\r\n";
Mail will be rejected from some mail servers if this date is missing.
-Craig

On 19/05/2009, at 5:54 PM, henson wrote:

henson

unread,
May 19, 2009, 5:27:24 PM5/19/09
to NZ PHP Users Group
HI Craig,

I've tried adding the date to the headers, Could you send me the php
mail() replacement code that uses SMTP.
Thanks
-Henson
> > I'm having this problem with sending HTML mail to my yahoo.com email.- Hide quoted text -
>
> - Show quoted text -

Craig Anderson

unread,
May 19, 2009, 6:03:29 PM5/19/09
to nzp...@googlegroups.com
Hi.
Ran across this one:
http://snipplr.com/view/5147/php--smtp-mail-class/
Which looks quite good. You should be able to replace
"mail.yourserver.com" with "localhost".
-Craig

Jevon Wright

unread,
May 19, 2009, 11:47:21 PM5/19/09
to nzp...@googlegroups.com
Try phpmailer, it's much, much easier than dealing with mail().

Jevon

henson

unread,
May 20, 2009, 3:51:11 AM5/20/09
to NZ PHP Users Group
HI Guys,

I tried out putting 'localhost' as the SMTP server and it didn't work.

I know this might sound stupid, but I have to ask this learn if I want
to learn.
How do I find out my the SMTP server of my website?
as both phpmailer and the SMTP class Craig suggested needs this.

Henson

On May 20, 3:47 pm, Jevon Wright <je...@jevon.org> wrote:
> Try phpmailer, it's much, much easier than dealing with mail().
>
> Jevon
>
> On Wed, May 20, 2009 at 10:03 AM, Craig Anderson <crai...@orangecat.co.nz>wrote:
>
>
>
>
>
> > Hi.
> > Ran across this one:
> >http://snipplr.com/view/5147/php--smtp-mail-class/
> > Which looks quite good. You should be able to replace
> > "mail.yourserver.com" with "localhost".
> > -Craig
>
> > On 20/05/2009, at 9:27 AM, henson wrote:
>
> > > HI Craig,
>
> > > I've tried adding the date to the headers,  Could you send me the php
> > > mail() replacement code that uses SMTP.
> > > Thanks
> > > -Henson
>
> > > On May 20, 6:44 am, Craig Anderson <crai...@orangecat.co.nz> wrote:
> > >> Hi.
> > >> Oh yes, one other thing.  You should include an RFC822 date in the
> > >> headers.  So add something like:
> > >>          $mdate = gmdate("r", time());
> > >>          $headers .= "Date: $mdate\r\n";
> > >> Mail will be rejected from some mail servers if this date is missing.
> > >> -Craig
>
> > >> On 19/05/2009, at 5:54 PM, henson wrote:
>
> > >>> I'm having this problem with sending HTML mail to my yahoo.com
> > >>> email.- Hide quoted text -
>
> > >> - Show quoted text -- Hide quoted text -

henson

unread,
May 20, 2009, 3:56:26 AM5/20/09
to NZ PHP Users Group
I just asked my friend to run my script from his site and I received
an email in my Yahoo mail although it went into the spam folder. At
least, it went in. Could it be my mail server is blocked or
something? I ran a diagnostic on my website on http://www.mxtoolbox.com/diagnostic.aspx
and it came back saying REVERSE DNS failed.

Henson

On May 20, 3:47 pm, Jevon Wright <je...@jevon.org> wrote:
> Try phpmailer, it's much, much easier than dealing with mail().
>
> Jevon
>
> On Wed, May 20, 2009 at 10:03 AM, Craig Anderson <crai...@orangecat.co.nz>wrote:
>
>
>
>
>
> > Hi.
> > Ran across this one:
> >http://snipplr.com/view/5147/php--smtp-mail-class/
> > Which looks quite good. You should be able to replace
> > "mail.yourserver.com" with "localhost".
> > -Craig
>
> > On 20/05/2009, at 9:27 AM, henson wrote:
>
> > > HI Craig,
>
> > > I've tried adding the date to the headers,  Could you send me the php
> > > mail() replacement code that uses SMTP.
> > > Thanks
> > > -Henson
>
> > > On May 20, 6:44 am, Craig Anderson <crai...@orangecat.co.nz> wrote:
> > >> Hi.
> > >> Oh yes, one other thing.  You should include an RFC822 date in the
> > >> headers.  So add something like:
> > >>          $mdate = gmdate("r", time());
> > >>          $headers .= "Date: $mdate\r\n";
> > >> Mail will be rejected from some mail servers if this date is missing.
> > >> -Craig
>
> > >> On 19/05/2009, at 5:54 PM, henson wrote:
>
> > >>> I'm having this problem with sending HTML mail to my yahoo.com
> > >>> email.- Hide quoted text -
>
> > >> - Show quoted text -- Hide quoted text -

Michael

unread,
May 20, 2009, 5:55:33 AM5/20/09
to nzp...@googlegroups.com
On Wed, 20 May 2009 19:56:26 henson wrote:
> I just asked my friend to run my script from his site and I received
> an email in my Yahoo mail although it went into the spam folder. At
> least, it went in. Could it be my mail server is blocked or
> something? I ran a diagnostic on my website on
> http://www.mxtoolbox.com/diagnostic.aspx and it came back saying REVERSE
> DNS failed.

What's the IP address of the mail server?

Michael

Craig Anderson

unread,
May 20, 2009, 2:48:25 PM5/20/09
to nzp...@googlegroups.com
Hi,
Most website also do mail for your domain, so check the mail settings,
particularly those for outbound (SMTP) to find the mail server. For
many websites this is just mail.yourdomain.co.nz... Sometimes using
"localhost" is better, sometimes not (depends on your host).

But you didn't say why it's not working -- mail isn't being sent at
all or just not being sent to yahoo?
-Craig

On 20/05/2009, at 7:51 PM, henson wrote:
> I tried out putting 'localhost' as the SMTP server and it didn't work.
>

Craig Anderson

unread,
May 20, 2009, 3:16:00 PM5/20/09
to nzp...@googlegroups.com
Hi Henson,
Reverse DNS failure for a mail server will certainly cause email to be
rejected from some sites. This could be a problem, but you'd have to
know the details of how the mailservers were configured at your host,
because you can't be certain that mail will be sent from the same
server as your website. Switching from "localhost" to something like
"mail.yourdomain.co.nz" might fix the problem (if it means mail is
sent from a different server), but no guarantees.

Certainly you should make sure the From: address in your email is
valid and there isn't a mistake in the domain.

Now the spam thing is a different problem. One of the problems with
the content of your email is that you've used HTML only. Many sites
take this to be spam because email clients are not required to support
HTML. If you want to send HTML mail it should really be sent as
multipart/alternative content mime (with both a plain text message and
an HTML message). PHPMailer will help you do this -- you can compose
multipart/alternative content mime messages yourself, but i'd strongly
suggest you don't do this because there are too many details that need
to be right, otherwise you'll have different problems with just some
recipients.
-Craig

henson

unread,
May 21, 2009, 6:23:46 AM5/21/09
to NZ PHP Users Group
I just checked my email tonight and all the missing emails just came
in, as in over 20 emails with the dates the attempts were made. And I
just ran the same script again from my site. It now receives the html
email. ????? so I'm a bit puzzled on what was happening the past
week.
I've just ran the same test I did on http://www.mxtoolbox.com/diagnostic.aspx
and the Reverse DNS error no longer is there,So it could be the cause
of my problems before. But what puzzles me is the script I ran this
morning and tonight is the same so sometime during the day, the
Reverse DNS error got resolved.

Thanks guys.
> > something?  I ran a diagnostic on my website onhttp://www.mxtoolbox.com/diagnostic.aspx
Reply all
Reply to author
Forward
0 new messages