tags:

views:

461

answers:

4

Hi all,
I have a simple email sender for user account activation. Depending on which email address I use, I get significantly different response times: University email - 1 minute, Gmail - 3-4 hours, Yahoo - 1 or 2 days -- which seems bizarre. Has anyone else seen this phenomenon?

EDIT:

There weren't many responses (even for a bounty), but I'll try to explain my problem more clearly.

This probably isn't greylsting -- If I so a simple:

php mail ($to, $subject, $body) // this delivers instantly.

My cakephp code:

    function __sendActivationEmail($id) {
    $User = $this->User->read ( null, $id );
    $this->set ( 'suffix_url', $User ['User'] ['id'] . '/' . $this->User->getActivationHash () );
    $this->set ( 'username', $User ['User'] ['username'] );
    $this->Email->to = $User ['User'] ['email'];
    $this->Email->subject = 'Test.com - ' . __ ( 'please confirm your email address', true );
    $this->Email->from = '[email protected]';
    $this->Email->template = 'user_confirm';
    $this->Email->sendAs = 'text';
    $this->Email->delivery = 'mail';
    $this->Email->send ();
}

Causes delays from 13 minutes (ok; we'll deal with it) to 5-6 hours (less okay, since this is an activation email). For some of my users, it works instantly, but for other users (of the same service provider, i.e., gmail, it sees these delays).

Any clues?

+1  A: 

The code looks fine, but it of course doesn't tell anything about the mail server's configuration. 3-4 hours I would put down to Greylisting, but 1-2 days is definitely too much. Is this reproducible? How many addresses have you tried this with?

What do the full headers of the (received) mails look like? The "received from: .... "path should tell you at which point it took 1-2 days to deliver.

Pekka
It seems like regular php mail() works fine with all email addresses... must be something with cake?What's Greylisting?
Michael
Nevermind-- I understand greylisting -- any other suggestions?
Michael
Can you post a comparison between (received) mail headers sent using mail() and through cake? What does the "received" path say? Every hopping point of the mail is listed there with date and time.
Pekka
I was not able to reproduce the 1-2 day event as I have not yet gotten a reply from several other tests I did. The 5 hour one is show above. Any ideas?
Michael
Is the 127.0.0.1 address in the mail for real? If it is, that's almost certainly wrong, it should be your server's external IP address. But I see a difference of only 1.5 hours (take note of the time zones). That *could* be o.k. and down to greylisting.
Pekka
Yes the 127.0.0.1 is real -- will look into it
Michael
Regarding the greylisting -- have you set up domainkeys/sender ID records?
Jesse Weigert
No I haven't -- how does this work with cakephp?
Michael
I would be interested to hear if they are, but I've never heard of domainkeys nor sender ID records being actively used in everyday mail traffic. Got any sources on the topic?
Pekka
A: 

Maybe you can install PHPMailer as a Vendor and create a Component called "Mail"...

And don't forget to authenticate with your SMTP server! :)

TiuTalk
A: 

Ignore the whole PHP element of it for a moment.

If its a linux server for example, send a mail from the command line e.g. mail [email protected]

see if the same thing is happening that way. Its quite likely its a server configuration issue not a php or cakePHP issue.

Look up a few basics like having a FQDN and maybe look into setting up SPF records for your email. Make sure the emails are coming from your domain name not someone elses e.g. not the users email.

Also check if you have email spam software set up that could be grey listing you email on the way out (unlikely but possible). the mostly like thing is the destination spam filter is delaying it. Try send to a gmail account and see if it gets through fine or goes into spam.

Do all this without touching PHP, if all is going fine there then set up a basic php script to do a basic email not using CakePHP, if that works fine then you know its CakePHP etc but I doubt it.

Derek Organ
in saying that, the other factor is it could be the content of the email has a heavy match to spam email.. so maybe change the text around a bit.
Derek Organ
The thing is, PhP Mail sends without delay -- since I also did not believe Cakephp would be the problem, I'm more inclined to go with the text used in the registration email -- I will fiddle around with this.
Michael
A: 

So after further digging, I realized that it was our server host's problem. We use Slicehost, and it just so happens that a range of ips that had been blacklisted included our own ip. We got our name off the list, and we're good to go.

Michael