开发者

CakePHP email component smtp failing

I've been successfully using CakePHP's email component to send my email but due to restrictions I now need to set it up to use a smtp relay server and I'm getting some strange results.

Here is my code:

$this-开发者_运维问答>Email->to = $user['User']['username'].' <'.$user['User']['email'].'>';
$this->Email->subject = 'MyWebsite.com – Please confirm your email address';
    $this->Email->from = 'MyWebsite.com <noreply@MyWebsite.com>';
    $this->Email->template = 'user_confirm';
    $this->Email->sendAs = 'html';
    $this->Email->smtpOptions = array(
        'timeout' => '30',
        'port' => '25',
        'host' => 'mail.myrelayserver.com',
        'username' => 'USERNAME',
        'password' => 'PASSWORD'
    );
    $this->Email->delivery = 'smtp';
    if ($this->Email->send()) {
        return true;
    } else {
        echo $this->Email->smtpError;
    }

Now whenever I try and send this email, the send fails and I get the following ouput from $this->Email->smtpError:

14.2/Kp; Sun, 14 Feb 2010 19:11:07 GMT

Any ideas?


"14.2/Kp; Sun, 14 Feb 2010 19:11:07 GMT" is a part of sendmail's 'greeting' message. Perhaps connection is dropped before authorization? Did you try connecting with netcat or telnet to your relay?


Fixed.

The problem was something to do with my smtp relay server not accepting connections from my cloud server. As soon as I added the following lines to the sendmail configuration file, email started coming through.

MASQUERADE_AS(`mydomain.com')dnl FEATURE(masquerade_envelope)dnl

I hope this helps somebody else :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜