Send mail using Phpmailer in the YII framework (2011-06-02 14:06:23)

Source: Internet
Author: User
Tags yii

reproduced
Tags:it Category: Technology sharing

Official extension Link: http://www.yiiframework.com/extension/mailer/
This extension configuration is very convenient, if there is a problem, you can open debug:
    1. <? PHP
    2. $message = ' Hello world! ';
    3. $mailer = yii::createcomponent (' Application.extensions.mailer.EMailer ');
    4. $mailer->host = <your smtp host>;
    5. $mailer->issmtp ();
    6. $mailer->from = ' [email protected] ';
    7. $mailer->addreplyto (' [email protected] ');
    8. $mailer->addaddress (' [email protected] ');
    9. $mailer->fromname = ' Wei Yard ';
    10. $mailer->smtpdebug = true;//Set Smtpdebug to True, you can turn on the debug function and follow the prompts to modify the configuration
    11. $mailer->charset = ' UTF-8 ';
    12. $mailer->subject = yii::t (' demo ', ' Yii rulez! ');
    13. $mailer->body = $message;
    14. $mailer->send ();
Because I use 163 mailbox as the sending address, this mail service needs to verify the function. Must be entereduser name and password to send success!
    1. <?php
    2. $message = ' Hello world! ';
    3. $mailer = yii::createcomponent (' Application.extensions.mailer.EMailer ');
    4. $mailer->host = ' smtp.163.com ';
    5. $mailer->issmtp ();
    6. $mailer->smtpauth = true;
    7. $mailer->from = ' [email protected] ';
    8. $mailer->addreplyto (' [email protected] ');
    9. $mailer->addaddress (' [email protected] ');
    10. $mailer->fromname = MyName ';
    11. $mailer->username = ' Username '; Enter the user name of the sender address here
    12. $mailer->password = ' Password '; Enter the password for the sending address here
    13. $mailer->smtpdebug = true;//Set Smtpdebug to True, you can turn on the debug function and follow the prompts to modify the configuration
    14. $mailer->charset = ' UTF-8 ';
    15. $mailer->subject = yii::t (' demo ', ' Yii rulez! ');
    16. $mailer->body = $message;
    17. $mailer->send ();
If you use a server that does not have a mail server installed, we can use this method to send mail!

Send mail with Phpmailer in the Yii framework (2011-06-02 14:06:23)

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.