555 5.5.2 语法错误。 gmail的smtp

发布于 2024-10-05 12:23:46 字数 1133 浏览 8 评论 0原文

你知道什么是语法错误吗?

这是我使用 cakephp 的代码

 $User = $this->User->read(null,$id);
    $this->Email->to = array('[email protected]');; 
    $this->Email->from = '[email protected]';
    $this->Email->subject = 'Welcome to our really cool thing';
    $this->Email->template = 'simple_message'; 

    $this->Email->sendAs = 'both'; 
     $this->Email->smtpOptions = array(
        'port'=>'465', 
        'timeout'=>'30',
        'auth' => true,
        'host' => 'ssl://smtp.gmail.com',
        'username'=>'[email protected]',
        'password'=>'********',

   );
    $this->set('User', $User);
    $this->Email->delivery = 'smtp';
    $this->Email->send();

注意:我将电子邮件发送给自己用于测试目的。

Do you know what is syntax error refering?

Here's the code I'm using cakephp

 $User = $this->User->read(null,$id);
    $this->Email->to = array('[email protected]');; 
    $this->Email->from = '[email protected]';
    $this->Email->subject = 'Welcome to our really cool thing';
    $this->Email->template = 'simple_message'; 

    $this->Email->sendAs = 'both'; 
     $this->Email->smtpOptions = array(
        'port'=>'465', 
        'timeout'=>'30',
        'auth' => true,
        'host' => 'ssl://smtp.gmail.com',
        'username'=>'[email protected]',
        'password'=>'********',

   );
    $this->set('User', $User);
    $this->Email->delivery = 'smtp';
    $this->Email->send();

NOTE: I'm sending the email to myself for test purposes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

初雪 2024-10-12 12:23:47

这里提出了这个问题:Cakephp SMTP电子邮件语法错误

这是RabidFire的(正确)答案:

Google 的 SMTP 要求您格式化
电子邮件地址的方式如下:

收件人姓名 [电子邮件受保护]>

对 from 和 to 都执行此操作
地址,然后您就可以出发了。
如果您不知道该人的姓名
用户,那么您可以重复
电子邮件:

$this->电子邮件->收件人 =
"[电子邮件受保护]
[电子邮件受保护]>";

This question was asked here: Cakephp SMTP emails syntax error

Here is RabidFire's (correct) answer:

Google's SMTP requires you to format
email addresses in the following way:

Recipient Name <[email protected]>

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 =
"[email protected]
<[email protected]>";

想挽留 2024-10-12 12:23:47

tofrom设置为“[电子邮件受保护] [电子邮件受保护]> ”不适合我。必须将两者更改为“<[电子邮件受保护]>”。将字符串放在 <> 之外部分失败,并显示“邮件发送失败 555 5.5.2 语法错误。.. - gsmtp”

setting to and from as "[email protected] <[email protected]>" was't working for me. Had to change both to "<[email protected]>". Putting a string outside the <> part fails with "Mail send failed 555 5.5.2 Syntax error. .. - gsmtp"

凉城凉梦凉人心 2024-10-12 12:23:47

今天刚收到其中一个,我正在使用的一个库在发送邮件之前将站点名称放在方括号中,并导致 555 5.5.2 语法错误。

最好不要在名称所在的地址的第一部分中没有任何符号。我的错误是由以下原因引起

"Name [Site] <[email protected]>"

并由以下原因修复的

"Name Site <[email protected]>"

Just got one of these today, a library I'm using puts the site name in square brackets before sending the mail and causes the 555 5.5.2 Syntax Error.

Your best off having no symbols in the first part of the addres where name should go. My error was caused by

"Name [Site] <[email protected]>"

and fixed by

"Name Site <[email protected]>"
桜花祭 2024-10-12 12:23:47

我遇到了这个问题,但使用像 dude.muñ[email protected] 并解决了更改为 dude.mu&#[email protected] (更改unicode 的特殊字符)。

I had this problem with but with an email like dude.muñ[email protected] and solved changing to dude.mu&#[email protected] (Changing the special characters with unicodes).

想念有你 2024-10-12 12:23:47

当“来自”字段为空或无效时,我收到此错误。因此,您不应在测试中使用虚假电子邮件。

I've got this error when "from" field was empty or not valid. So you shouldn't use fake email in your test.

我不在是我 2024-10-12 12:23:47

“你的名字”放在里面<> 发件人字段中的括号。

我正在使用 Erlang、Vagabond/gen_smtp 和 Gmail。

这是我的配置文件的一部分:

{email_conf, [
  {sender, <<"<YourName [email protected]>">>},
  {options, [
    {ssl, true},
    {port, 465},
    {relay, <<"smtp.gmail.com">>},
    {username, <<"[email protected]">>},
    {password, <<"...">>}
  ]}
]},

和功能:

send_html(Subject, Body, Sender, Receiver, Opts) ->
  Mimemail =
    {<<"text">>, <<"html">>,
      [
        {<<"From">>, Sender},
        {<<"To">>, Receiver},
        {<<"Subject">>, Subject},
        {<<"Content-Type">>, <<"text/html; charset=utf-8">>}
      ],
      [{<<"transfer-encoding">>, <<"base64">>}],
      Body},
  Mail = {Sender, [Receiver], mimemail:encode(Mimemail)},
  gen_smtp_client:send_blocking(Mail, Opts).

Put the "YourName" inside <> brackets in sender field.

I'm using Erlang, Vagabond/gen_smtp and Gmail.

This is a part of my config file:

{email_conf, [
  {sender, <<"<YourName [email protected]>">>},
  {options, [
    {ssl, true},
    {port, 465},
    {relay, <<"smtp.gmail.com">>},
    {username, <<"[email protected]">>},
    {password, <<"...">>}
  ]}
]},

and function:

send_html(Subject, Body, Sender, Receiver, Opts) ->
  Mimemail =
    {<<"text">>, <<"html">>,
      [
        {<<"From">>, Sender},
        {<<"To">>, Receiver},
        {<<"Subject">>, Subject},
        {<<"Content-Type">>, <<"text/html; charset=utf-8">>}
      ],
      [{<<"transfer-encoding">>, <<"base64">>}],
      Body},
  Mail = {Sender, [Receiver], mimemail:encode(Mimemail)},
  gen_smtp_client:send_blocking(Mail, Opts).
梦里的微风 2024-10-12 12:23:47

名称即可解决此问题

"Name <[email protected]>"

我们只需删除替换为的

"[email protected]"

We solved this issue just by removing the name

"Name <[email protected]>"

Replaced by

"[email protected]"
朱染 2024-10-12 12:23:47

其原因是消息格式不正确。可能是来自地址或到地址是错误的(比如一个额外的逗号之类的东西)

Its Due to message format is not correct. may be from address or to address is wrong(like a extra comma something)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文