555 5.5.2 Syntax error. gmail's smtp

2019-01-15 12:48发布

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.

标签: email smtp
5条回答
Fickle 薄情
2楼-- · 2019-01-15 13:31

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>"
查看更多
萌系小妹纸
3楼-- · 2019-01-15 13:37

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

查看更多
Lonely孤独者°
4楼-- · 2019-01-15 13:42

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).

查看更多
戒情不戒烟
5楼-- · 2019-01-15 13:43

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

查看更多
smile是对你的礼貌
6楼-- · 2019-01-15 13:47

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"

查看更多
登录 后发表回答