Zend Framework framework of the zend_mail implementation of sending email verification function and solve the title garbled method, Zendzend_mail
In this paper, the Zend_mail of Zend Framework framework is introduced to implement the verification function of email message and the method of solving the title garbled. Share to everyone for your reference, as follows:
Zend_mail This component in the Zend Framework is very handy. It provides a generalization of the ability to write messages with text content and, of course, it is also compatible with the MIME standard for multiple segments of the mail message. Zend_mail through the default Zend_mail_transport_sendmail transmission or can over Zend_mail_ TRANSPORT_SMTP to send us an email.
Zend_mail sends the simplest mail functionality. Send by Zend_mail_transport_sendmail. We just specify one recipient of the message, a subject, a message content and a sender. Its code is as follows (annotated:):
<?phprequire_once ' zend/mail.php '; $mail = new Zend_mail ("UTF-8");//Set Message encoding $mail->setbodytext (' your mail content is here!. ')/ /Send e-mail address and some sender's description information->setfrom (' fromemail@example.com ', ' sender's description information ')//recipient e-mail address and some addressee's explanatory information->addto (' Toemail@example.com ', ' message of the addressee ')//email header, address garbled->setsubject ("=? UTF-8? B? ". Base64_encode (' email header '). "? = ") ->send ();? >
Another is to send an e-mail message through an SMTP. However, you need to configure your mail server. This step can be Google a bit. I'm not here to say more. I am here to keep Google to send e-mails. After my test. My email to my gmail and 163 (NetEase) mailbox is no problem. Garbled problem also solved. The title length limit issue also does not appear: Used to be their own reference on the Internet to change the function inside the zend_mail. Now with the 1.6 version of the Zend framework there seems to be no such problem. I think the ZF team changed the bug in it ... Oh..
Here is the code of your own implementation:
<?phprequire_once Root_path. '/zend/mail.php '; require_once Root_path. '/zend/mail/transport/smtp.php '; $mail = new Zend_mail ("UTF-8");//Set message encoding $config = Array (' auth ' = ' login ', ' Username ' = ' + ' Kylingood ',//electronic user name ' password ' + ' Here is your email password ', ' SSL ' = ' SSL ', $transport = new Zend_mail_ TRANSPORT_SMTP (' smtp.gmail.com ', $config), $mail->setdefaulttransport ($transport); $mailcontent = ' Welcome to your arrival!
Your registration name is: '. $thisArray [' username ']. '
Your password is: '. $thisArray [' Userpass ']. '
Please click here Address: Activate your account! Please delete this message as soon as possible to prevent others from stealing your password
If you forget your password, you can write to the community and ask the administrator to reset the
'; $mail->setbodyhtml ($mailcontent); /can send HTML messages. It's convenient! $mail->setfrom (' kylingood@gmail.com ', ' Kylingood '); $mail->addto ($email, ' Kylingood '); $title = $thisArray [' username ']. ', user Hello, this is the website activation verification mail! '; $mail->setsubject ("=? UTF-8? B? ". Base64_encode ($title). "? = "); $mail->send ();?
All right.. It is this principle to send mail roughly with Zend_mail. There are, of course, more advanced points to use, such as sending attachments by mail. Send multiple e-mail messages at once. There is also the use of different transport objects to send different messages ... You can refer to the ZF Handbook to do ... I hope we can communicate more.
More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "
It is hoped that this article will help you to design PHP based on the Zend Framework framework.
Articles you may be interested in:
- Zend Framework+smarty Usage Example detailed
- Zend Framework implementation of Zend_view Integrated Smarty template system
- Code analysis of routing mechanism of Zend framework framework
- Zend Framework Implementation Message Sub-page function (with demo source download)
- Zend Framework implementation of basic functions of the message book (with demo source download)
- The Zend framework implements the method of storing the session in Memcache
- Zend Framework Paging Class usage
- Zend framework generate verification code and implement Verification Code verification function (with demo source download)
- Zend Framework Tutorial Zend_form component implement form submission and display Error prompt method
- Zend Framework implements multi-file upload function instances
- Zend Framework Introduction Environment configuration and the first Hello World example (with demo source download)
- Zend Framework Introductory Knowledge Point Summary
- Zend Framework Cache Usage Simple instance
- Zend Framework Smarty Extension Implementation method
http://www.bkjia.com/PHPjc/1113735.html www.bkjia.com true http://www.bkjia.com/PHPjc/1113735.html techarticle Zend Framework framework of the zend_mail implementation of the E-mail verification function and to solve the title garbled method, Zendzend_mail This article describes the Zend framework of the Zend_mail implementation of the Send E. ...