本文介紹了Cakephp SMTP 電子郵件語法錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在用蛋糕發(fā)送電子郵件時遇到了問題.我的方法是這樣的:
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!');
但是當我嘗試發(fā)送電子郵件時,我收到了:
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?
謝謝
推薦答案
Per RFC2821,Google 的 SMTP 服務(wù)器似乎是一個堅持者,電子郵件地址的格式應(yīng)如下所示:
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>
對 from
和 to
地址執(zhí)行此操作,您應(yīng)該很高興.如果您沒有用戶的姓名,則只需重復電子郵件即可:
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>";
這篇關(guān)于Cakephp SMTP 電子郵件語法錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!