国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) Zend_Mail implements the verification function of sending email and solves the problem of garbled title

Zend_Mail implements the verification function of sending email and solves the problem of garbled title

Dec 26, 2016 pm 03:44 PM

The example of this article describes the Zend_Mail of the Zend Framework framework to implement the verification function of sending email and solve the method of garbled title. I share it with you for your reference. The details are as follows:

The Zend_Mail component in Zend Framework is very convenient to use. It provides a universal way to write and send emails with text content. Of course, it is also compatible with the MIME standard. The function of multiple multi-segment email messages. Zend_Mail uses the default Zend_Mail_Transport_SendMail transport or can send our emails through Zend_Mail_Transport_Smtp.

Zend_Mail is the simplest email function. Send it through Zend_Mail_Transport_Sendmail. We only need to specify a recipient, a subject, an email content and a sender of the email. The code is as follows (with comments:):

<?php
require_once &#39;Zend/Mail.php&#39;;
$mail = new Zend_Mail("UTF-8");//設(shè)置郵件編碼
$mail->setBodyText(&#39;你的郵件內(nèi)容放在這里!.&#39;) //發(fā)送電子郵件地址以及一些發(fā)送人的說明信息
->setFrom(&#39;fromemail@example.com&#39;, &#39;發(fā)送人的說明信息&#39;) //收信人電子郵件地址以及一些收信人的說明信息
->addTo(&#39;toemail@example.com&#39;, &#39;收信人的說明信息&#39;) //電子郵件標(biāo)題,解決亂碼
->setSubject("=?UTF-8?B?".base64_encode(&#39;電子郵件標(biāo)題&#39;)."?=")  ->send();
?>

The other one is to send an email through an SMTP Email. But you need to configure your email server. You can go to GOOGLE for this step. I won’t say more here. I can use GOOGLE to send emails here. After my test, my email There is no problem when emails are sent to my Gmail and 163 (NetEase) mailboxes. The garbled code problem has also been solved. The title length limit problem has not appeared either. In the past, I changed the functions in Zend_Mail by referring to the Internet. Now I use 1.6 The version of Zend Framework doesn't seem to have such a problem... I think the ZF team has fixed the bug in it... Haha...

The following is the code of my own implementation:

<?php
require_once ROOT_PATH . &#39;/Zend/Mail.php&#39;;
require_once ROOT_PATH . &#39;/Zend/Mail/Transport/Smtp.php&#39;;
$mail = new Zend_Mail("UTF-8");//設(shè)置郵件編碼
$config = array(
 &#39;auth&#39;=>&#39;login&#39;, &#39;username&#39;=>"kylingood",//電子件用戶名
 &#39;password&#39;=>"這里是填寫你電子郵件密碼",
 &#39;ssl&#39;=>"ssl"
);
$transport = new Zend_Mail_Transport_Smtp(&#39;smtp.gmail.com&#39;,$config);
$mail->setDefaultTransport($transport);
$mailcontent=&#39;歡迎您的到來!<br /> 您的注冊名為:
&#39;.$thisArray [&#39;username&#39;].&#39;<br /> 您的密碼為:&#39;.$thisArray [&#39;userpass&#39;].&#39;
<br /> 請您點擊這里的地址:<a href="#"><font color="red">激活
</font> </a>您的帳號!
請盡快刪除此郵件,以免別人偷看到您的密碼<br /> 如果忘了密碼,
可以到社區(qū)寫信請管理員重新設(shè)定<br />&#39;;
$mail->setBodyHtml($mailcontent);//可以發(fā)送HTML的郵件.真方便! 
$mail->setFrom(&#39;kylingood@gmail.com&#39;, &#39;kylingood&#39;);
$mail->addTo($email, &#39;kylingood&#39;); $title=$thisArray [&#39;username&#39;].&#39;,用戶您好,這是網(wǎng)站激活驗證郵件!&#39;;
$mail->setSubject("=?UTF-8?B?".base64_encode($title)."?=");
$mail->send();
?>

Okay Okay.. This is basically the principle of using Zend_Mail to send emails. Of course, there are more advanced uses. For example, sending attachments via email, sending multiple emails at one time, and using different Transport objects to send them. Different emails... You can refer to the ZF manual to do it... I hope you can communicate more...

I hope this article will be helpful to everyone's PHP programming based on the Zend Framework framework.

For more Zend_Mail implementation of verification function for sending emails and methods to solve garbled headers, please pay attention to the PHP Chinese website for email-related articles!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276