Cakephp SMTP 电子邮件语法错误

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

问题描述

我在用蛋糕发送电子邮件时遇到了问题.我的方法是这样的:

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?

谢谢

推荐答案

Per RFC2821,Google 的 SMTP 服务器似乎是一个坚持者,电子邮件地址的格式应如下所示:

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>

fromto 地址执行此操作,您应该很高兴.如果您没有用户的姓名,则只需重复电子邮件即可:

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 电子邮件语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Codeigniter htaccess to remove index.php and www(Codeigniter htaccess 删除 index.php 和 www)
htaccess mod_rewrite part of url to GET variable(htaccess mod_rewrite url 的一部分到 GET 变量)
Replacing a querystring parameter value using mod_rewrite(使用 mod_rewrite 替换查询字符串参数值)
.htaccess in subdirectory #39;overriding#39; parent htaccess(子目录“覆盖父 htaccess 中的 .htaccess)
How to rewrite SEO friendly url#39;s like stackoverflow(如何像stackoverflow一样重写SEO友好的url)
Is it okay to have a very long .htaccess file?(有一个很长的 .htaccess 文件可以吗?)