Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...