Yii uses PHPMailer to send emails

Source: Internet
Author: User
Yii how to use PHPMailer to send emails

As a common component:

In this example, use SMTP as the sending method to create a component in the controller:

12345678910111213 Host = ; $ Mailer-> IsSMTP (); $ mailer-> From = 'Wei @ example.com '; $ mailer-> AddReplyTo ('Wei @ example.com '); $ mailer-> AddAddress ('Qiang @ example.com '); $ mailer-> FromName = 'Wei Yard'; $ mailer-> CharSet = 'utf-8 '; $ mailer-> Subject = Yii: t ('demo', 'yii rulez! '); $ Mailer-> Body = $ message; $ mailer-> Send ();

As application component: Configuration File Code (note the pathViews and pathLayouts parameters ):

123456789 Array ('mailer' => array ('class' => 'application. extensions. mailer. EMailer ', 'pathviews' => 'application. views. email ', 'pathlayouts' => 'application. views. email. layouts '),//...}

Controller code:

1234567891011 Mailer-> Host = 'smtp .yiiframework.com '; Yii: app ()-> mailer-> IsSMTP (); Yii: app () -> mailer-> From = 'Wei @ pradosoft.com '; Yii: app ()-> mailer-> FromName = 'Wei'; Yii: app () -> mailer-> AddReplyTo ('Wei @ pradosoft.com '); Yii: app ()-> mailer-> AddAddress ('Qian @ yiiframework.com'); Yii: app () -> mailer-> Subject = 'yii rulez! '; Yii: app ()-> mailer-> Body = $ message; Yii: app ()-> mailer-> Send ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.