Zend Framework Mail sends mail through NetEase free mailbox

As a hard-working individual webmaster, if you want to make a small website, there are not many people who are willing to watch it, and then you can get a membership system that can't retrieve your password? Basically sentenced to death. Aliyun's SMS also costs money, and it only supports PHP 5.5 and above. My website is still at the level of PHP 5.3. upgrade? Afraid of causing new trouble. Anyway, in mainland China, you use the server to send mail, and other mail servers will not receive it. I used Postfix on the server and tested it with command line mail. Can't send.

Therefore, I want to use the mail servers of major websites to do it for me, but QQ mailboxes cannot and Sina mailboxes cannot. Please correct me if I'm wrong. Later, I saw someone on the Internet saying that NetEase's mailbox is OK, so I registered for one to try. As a result, it really can! Netease is great! Thanks!

After opening the mailbox, you must apply for an authorization code, which is the password to be used in the program. Methods as below:

163 How to start the POP3 protocol and obtain the authorization code for the mailbox

Then, I found this masterpiece, thanks to the two authors!

Zend_Mail of Zend Framework realizes the verification function of sending Email and the method to solve the garbled title

Of course, some people also use PHPMAILER, my application is to send an email to a member, and let him go to a special channel to modify the member's password, and he can send a letter. This method uses the Mail library of Zend Framework.

    //当然了,你前面得判断一下那个邮箱有没有注册会员
	require_once 'Zend/Mail.php';
	require_once 'Zend/Mail/Transport/Smtp.php';
	$mail = new Zend_Mail("UTF-8");//设置邮件编码
	$config = array(
		'auth' => "login", 
		'username' => "somebody",//电子件用户名
		'password' => "dont tell you", //这就是申请来的授权码
		'ssl' => "ssl" //这个要开通php.ini中的OpenSSL
	);
								
	$transport = new Zend_Mail_Transport_Smtp('smtp.163.com',$config);
	$mail->setDefaultTransport($transport);

	$title ="找回密码邮件";								
	$mailcontent='我在测试呢,看看好不好使!';
	$mail->setBodyHtml($mailcontent); //可以发送HTML的邮件.真方便! 
	$mail->setFrom('[email protected]', 'ypgogo');
	$mail->addTo($email, 'somebody'); $title=',用户您好,这是网站激活验证邮件!';
	$mail->setSubject("=?UTF-8?B?".base64_encode($title)."?=");
	if($mail->send())

The first letter was sent to QQ mailbox, but it didn't go into the trash, I'm so happy!

Before the success, there was a timeout error because SSL was not used. The error message is as follows:

Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Connection timed out'

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325352507&siteId=291194637