4

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?

Thanks

Elwhis
  • 1,241
  • 2
  • 23
  • 45

1 Answers1

11

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>

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>";
Community
  • 1
  • 1
RabidFire
  • 6,280
  • 1
  • 28
  • 24
  • 1
    This isn't working for me. Same EXACT problem... Have there been any updates or any other reasons why this syntax error might occur? – BWelfel Apr 08 '11 at 05:02
  • You should really post some code to help us figure out where the problem might be. Also include the version of CakePHP you're using. – RabidFire Apr 10 '11 at 10:47
  • I still get the same msg: `MAIL FROM: Recipient Name ` `555 5.5.2 Syntax error. qh1si1152456pba.999` – vbence Nov 08 '12 at 16:15