Cakephp SMTP电子邮件语法错误 [英] Cakephp SMTP emails syntax error

查看:253
本文介绍了Cakephp SMTP电子邮件语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在电子邮件发送时遇到问题。我的方法看起来像这样:

  $ this-> Email-> smtpOptions = array(
'port' =''465',
'timeout'=> '30',
'auth'=> true,
'host'=>'ssl:// smtp。 gmail.com',
'username'=> areymail@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!');

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

  555 5.5.2语法错误。 l3sm512374fan.0 

为了这个工作,我需要什么chnage?



感谢

解决方案

Per RFC2821 ,Google的SMTP服务器似乎是一个粘贴者,电子邮件地址的格式应该如下:

 收件人名称< myname@example.com> 
-or-
< myname@example.com>

地址,你应该很好去。如果您没有用户名,则可以重复以下电子邮件:

  $ this->电子邮件 - > to =my_test_mail@centrum.cz< my_test_mail@centrum.cz>; 
-or-
$ this-> Email-> to =< my_test_mail@centrum.cz>;


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:

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. 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>";

这篇关于Cakephp SMTP电子邮件语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆