CakePHP-2.0: How can i send email from a gmail account using CakEmail and SMTP setting?

前端 未结 5 1283
醉酒成梦
醉酒成梦 2021-02-10 03:49

I\'m trying to send email from a gmail account using CakEmail and SMTP settings .

It would be nice if someone tell the process step by step what to do .

I have a

5条回答
  •  春和景丽
    2021-02-10 03:58

    Just set the from:

    from(array('my@gmail.com' => 'Your Name'));
    $email->to('foo@stackoverflow.com');
    $email->subject('Sent from Gmail');
    $email->send('My message'); // or use a template etc
    

    should do it.

    You may want to set the sender as well; I'm not 100% but I imagine it will be useful when sending email "from" gmail via your own website; perhaps to stop the email being picked up as spam.

    $email->sender('noreply@mydomain.com', 'MyApp emailer');

提交回复
热议问题