Cakephp SMTP电子邮件语法错误

Elw*_*his 4 php email smtp cakephp cakephp-1.3

电子邮件发送到蛋糕我有问题.我的方法看起来像这样:

$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!');
Run Code Online (Sandbox Code Playgroud)

但当我尝试发送电子邮件时,我得到:

555 5.5.2 Syntax error. l3sm512374fan.0
Run Code Online (Sandbox Code Playgroud)

我需要什么才能使其工作?

谢谢

Rab*_*ire 10

根据RFC2821,Google的SMTP服务器似乎更加贴近,电子邮件地址的格式应采用以下方式:

Recipient Name <myname@example.com>
-or-
<myname@example.com>
Run Code Online (Sandbox Code Playgroud)

为地址fromto地址执行此操作,您应该很高兴.如果您没有该用户的名称,那么您可以重复该电子邮件:

$this->Email->to = "my_test_mail@centrum.cz <my_test_mail@centrum.cz>";
-or-
$this->Email->to = "<my_test_mail@centrum.cz>";
Run Code Online (Sandbox Code Playgroud)