tags:

views:

131

answers:

2

I have a PEAR mailing script that is used to send newsletters from a clients website. I've used the same code before to produce another newsletter system and it has worked well and been used to send emails to various addresses, however our latest client hasn't been receiving any of the emails.

When the newsletter is sent from the site to the various subscribers, including gmail, hotmail, yahoo and our own company emails, the emails are received correctly by all but the clients email addresses. As there is nothing different between their mailing system and our own, which is run from the same hosting company, I have to conclude that it is something to do with the domain.

The emails are being sent to the addresses from the system, as I have a log file storing the email addresses when the mail out function is called, but the newsletter never appears in the inbox. I have created a new email account for the domain and that too isn't receiving the emails. It's not going into a spam folder as the webmail system marks spam by adding SPAM into the subject.

I've tried to log if there are any errors using the following

$mail =& Mail::factory('mail');

foreach($subscribers as $recipient)
{
    $send_newsletter = $mail->send($recipient, $headers, $body);

    // LOG INFO
    $message = $recipient;

    if($send_newsletter)
    {
        $message .= ' SENT';
    }
    elseif(PEAR::isError($send_newsletter))
    {
        $message .= ' ERROR: '.$send_newsletter->getMessage();
    }           
    $message .= ' | ';
    fwrite($log_file,$message);
}

However this simple returns SENT for all recipients, so in theory there isn't anything wrong with the mailing function. [EDIT - though I've just noticed that this may not work as i'm using the 'mail' type and error reporting seems to only apply for 'sendmail' or 'smtp' - is that true?)

I don't know a great deal about PEAR or the mailing function so I may be missing something important, but I'd have thought seeing the last thing to happen is sending the email out, and that seems to work, then it should reach the clients inbox.

What reasons are there that a specific domain would not be able to accept emails when other domains hosted eith the same company can.

Any help is greatly appreciated as the client and myself are getting both confused and frustrated by the whole thing.

Cheers

A: 

It seems that there was something going on with using the mail option for the factory setting. When I set it up as SMTP it sent to all email addresses properly.

If anyone has any idea why this is, please let me know. It's great to be able to sort something, but it's even better to know why something wasn't working.

andy-score
A: 

PHP's mail function will not actually deliver the email to the recipient's mailboxes. It simply delivers the mail to YOUR server's actual mail server software (postfix, sendmail, exim, etc..), and THAT's what will do the actual work of delivery.

Since most mails are going through, obviously the script's working. So check your server's mail log (/var/log/maillog on most Unix-like systems) and search for the email address in question. If there's a problem delivering it to the recipient's mail server, it will be logged there.

Reasons for delivery failure:

a) receiving mail server (the client's) is VERY picky about mail headers and your server's sending out something in a too-relaxed format b) Your server's on one or more (either directly or via fallout from an entire netblock being listed) anti-spam RBL lists the client server subscribes to c) client server does greylisting, and your server gives up before the greylist timeout period expires

No matter what it is, comb through your mail server's logs to see what's happening with the recipient's email address. If it's bounced for any reason, it will be logged and you can work from there. If it turns out the mail's delivered (a "250 OK" type message is the delivery status), then it's something on the client end and you'll need their help debugging it, as the email was successfully delivered to their system.

Marc B
Thanks Marc for your response, helps me to understand how it all works. I'll have a look into the server logs and see what I come across.The main bit that confuses me is that both the clients mail servers and my own companies are hosted by the same provider and controlled by us (though probably not on the same shared server) as is the servers sending the emails (though this is a dedicated server), so in theory it should have the same blacklisting stuff for both if that was the problem.
andy-score