开发者

555 5.5.2 Syntax error. gmail's smtp

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('name@gmail.com');; 
    $this->Email->from = 'name@gmail.com';
    $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'=>'name@gmail.com',
        'password'=>'********',

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

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


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


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


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] <address@site.com>"

and fixed by

"Name Site <address@site.com>"


I had this problem with but with an email like dude.muñoz@domain.com and solved changing to dude.mu&#241oz@domain.com (Changing the special characters with unicodes).


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


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 your_gmail_address@gmail.com>">>},
  {options, [
    {ssl, true},
    {port, 465},
    {relay, <<"smtp.gmail.com">>},
    {username, <<"your_gmail_address@gmail.com">>},
    {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).


We solved this issue just by removing the name

"Name <address@site.com>"

Replaced by

"address@site.com"


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜