简体   繁体   English

CakePHP电子邮件组件smtp失败

[英]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. 我已经成功使用CakePHP的电子邮件组件发送电子邮件,但是由于限制,我现在需要对其进行设置以使用smtp中继服务器,并且得到一些奇怪的结果。

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: 现在,每当我尝试发送此电子邮件时,发送都会失败,并且会从$ 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. “ 14.2 / Kp; Sun,2010年2月14日19:11:07 GMT”是sendmail的“问候”消息的一部分。 Perhaps connection is dropped before authorization? 也许连接在授权之前被断开了? Did you try connecting with netcat or telnet to your relay? 您是否尝试使用netcat或telnet连接到中继?

Fixed. 固定。

The problem was something to do with my smtp relay server not accepting connections from my cloud server. 问题与我的smtp中继服务器不接受来自云服务器的连接有关。 As soon as I added the following lines to the sendmail configuration file, email started coming through. 将以下行添加到sendmail配置文件后,电子邮件便开始通过。

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

I hope this helps somebody else :) 我希望这对其他人有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM