Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

555 5.5.2 Syntax error. gmail's smtp

Tags:

email

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('[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.

like image 901
juan Avatar asked Dec 01 '10 05:12

juan


2 Answers

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

like image 118
Chaim Avatar answered Jan 01 '23 21:01

Chaim


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"

like image 36
Paul-Armand Verhaegen Avatar answered Jan 01 '23 21:01

Paul-Armand Verhaegen