简体   繁体   English

Cakephp SMTP电子邮件语法错误

[英]Cakephp SMTP emails syntax error

I've got a problem with email sending in cake. 电子邮件发送到蛋糕我有问题。 My method looks like this: 我的方法看起来像这样:

$this->Email->smtpOptions = array(
            'port'=>'465', 
            'timeout'=>'30',
            'auth' => true,
            'host' => 'ssl://smtp.gmail.com',
            'username'=>'mymail@gmail.com',
            'password'=>'mypass',
        );

        $this->Email->from    = "admin@localhost";
        $this->Email->to      = "my_test_mail@centrum.cz";
        $this->Email->subject = "Test";
        $this->Email->sendAs = "text";

        $this->Email->delivery = 'smtp';

        $this->Email->send('Hello message body!');

But when I try to send the email I get: 但当我尝试发送电子邮件时,我得到:

555 5.5.2 Syntax error. l3sm512374fan.0

What do I need to chnage in order for this to work? 我需要什么才能使其工作?

Thanks 谢谢

Per RFC2821 , to which Google's SMTP servers seem to be a stickler on, the format of the email addresses should be in the following way: 根据RFC2821 ,Google的SMTP服务器似乎更加贴近,电子邮件地址的格式应采用以下方式:

Recipient Name <myname@example.com>
-or-
<myname@example.com>

Do this for both the from and to address, and you should be good to go. 这样做既可以fromto解决,你应该好好去。 If you don't have the name of the user, then you can just repeat the email: 如果您没有该用户的名称,那么您可以重复该电子邮件:

$this->Email->to = "my_test_mail@centrum.cz <my_test_mail@centrum.cz>";
-or-
$this->Email->to = "<my_test_mail@centrum.cz>";

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

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