Zend_Mail In the Zend Framework implements the Email sending verification function and solves the title garbled by zendzend_mail.
This example describes how to use Zend_Mail In the Zend Framework to verify Email sending and how to fix title garbled characters. We will share this with you for your reference. The details are as follows:
The Zend_Mail component in Zend Framework is very convenient to use .. it provides generic compilation and sending of text content emails. Of course, it is also compatible with the MIME standard multi-segment mail message function. in Zend_Mail, use the default Zend_Mail_Transport_SendMail for transmission or use Zend_Mail_Transport_Smtp to send our email.
Zend_Mail provides the simplest email sending function. sent via Zend_Mail_Transport_Sendmail. you only need to specify one email recipient, one subject, one email content, and one sender. its code is as follows (with annotations :):
<? Phprequire_once 'zend/Mail. php'; $ mail = new Zend_Mail ("UTF-8"); // set the email code $ mail-> setBodyText ('Put your email content here !. ') // The sender's email address and description of some senders-> setFrom ('fromemail @ example.com', 'sender's description information ') // recipient's email address and description of some recipients-> addTo ('email @ example.com ', 'recipient's description information') // email title, fix Garbled text-> setSubject ("=? UTF-8? B? ". Base64_encode ('email title ')."? = ")-> Send ();?>
The other is to send an email via SMTP. however, you need to configure your email server. in this step, You can GOOGLE it .. I will not talk about it here. I can keep GOOGLE here to send emails .. after my tests. I sent emails to my Gmail and Netease mailboxes. the garbled problem is also solved .. the title length restriction problem does not occur either .. I used to modify the Zend_Mail function on the Internet .. the Zend Framework of version 1.6 does not seem to have such a problem .. I think the ZF team has changed the BUG... haha ..
The following is your own implementation code:
<? Phprequire_once ROOT_PATH. '/Zend/Mail. php '; require_once ROOT_PATH. '/Zend/Mail/Transport/Smtp. php '; $ mail = new Zend_Mail ("UTF-8"); // set the email encoding $ config = array ('auth' => 'login ', 'username' => "kylingood", // electronic mail username 'Password' => "here is your email password", 'ssl '=> "ssl "); $ transport = new Zend_Mail_Transport_Smtp ('smtp .gmail.com ', $ config); $ mail-> setDefaultTransport ($ transport); $ mailcontent =' Welcome! <Br/> your registration name is :'. $ thisArray ['username']. '<br/> your password is :'. $ thisArray ['userpass']. '<br/> click here: <a href = "#"> <font color = "red"> activate </font> </a> your account! Please delete this email as soon as possible to prevent others from peeking at your password <br/> if you forget your password, you can write a letter to the community and ask the Administrator to reset it <br/> '; $ mail-> setBodyHtml ($ mailcontent); // you can send HTML emails. really convenient! $ Mail-> setFrom ('kylingood @ gmail.com ', 'kylingood'); $ mail-> addTo ($ email, 'kylingood '); $ title = $ thisArray ['username']. ', hello, this is the website activation verification email! '; $ Mail-> setSubject ("=? UTF-8? B? ". Base64_encode ($ title )."? = "); $ Mail-> send ();?>
Okay .. generally, Zend_Mail is used to send emails .. of course there are more advanced usage points. for example, sending an attachment via email .. send multiple emails at a time. there is also the use of different Transport objects to send different emails... you can refer to the ZF manual to do this... I hope you can talk more ..