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:
- <? PHP
- $message = ' Hello world! ';
- $mailer = yii::createcomponent (' Application.extensions.mailer.EMailer ');
- $mailer->host = <your smtp host>;
- $mailer->issmtp ();
- $mailer->from = ' [email protected] ';
- $mailer->addreplyto (' [email protected] ');
- $mailer->addaddress (' [email protected] ');
- $mailer->fromname = ' Wei Yard ';
- $mailer->smtpdebug = true;//Set Smtpdebug to True, you can turn on the debug function and follow the prompts to modify the configuration
- $mailer->charset = ' UTF-8 ';
- $mailer->subject = yii::t (' demo ', ' Yii rulez! ');
- $mailer->body = $message;
- $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!
- <?php
- $message = ' Hello world! ';
- $mailer = yii::createcomponent (' Application.extensions.mailer.EMailer ');
- $mailer->host = ' smtp.163.com ';
- $mailer->issmtp ();
- $mailer->smtpauth = true;
- $mailer->from = ' [email protected] ';
- $mailer->addreplyto (' [email protected] ');
- $mailer->addaddress (' [email protected] ');
- $mailer->fromname = MyName ';
- $mailer->username = ' Username '; Enter the user name of the sender address here
- $mailer->password = ' Password '; Enter the password for the sending address here
- $mailer->smtpdebug = true;//Set Smtpdebug to True, you can turn on the debug function and follow the prompts to modify the configuration
- $mailer->charset = ' UTF-8 ';
- $mailer->subject = yii::t (' demo ', ' Yii rulez! ');
- $mailer->body = $message;
- $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)