Objective:
yesterday with a mobile phone accidentally point a Bo asked, saw a friend asked a question about PHP send email can not add the name of the problem, try to read the code, feel that they found the problem, who knows just smattering didn't really find the problem, it seems there is a period of time without writing code is going to go wrong, Learning is a process, not that today I read a book, Tomorrow is good, choose a good direction to go ahead. This article original blog address: http://www.cnblogs.com/unofficial official website address:www.pushself.com)
Knowledge Point Recall Study:
Use Phpmailer plug-in to send mail, on GitHub clone under a code, try to learn, and realize the delivery of mail, this is today's learning task.
To borrow an exact word " phpmailer-a full-featured Email creation and transfer class for PHP ", downloading the code down too much, looking a little annoyed, directly into the subject. How do I use it? A simple example. This article original blog address: http://www.cnblogs.com/unofficial official website address:www.pushself.com)
<?PHPrequire' Phpmailerautoload.php ';$mail=NewPhpmailer;$mail->ISSMTP ();//Set Mailer to use SMTP$mail->host = ' smtp1.example.com;smtp2.example.com ';//Specify main and backup SMTP servers$mail->smtpauth =true;//Enable SMTP Authentication$mail->username = ' [email protected] ';//SMTP username$mail->password = ' secret ';//SMTP Password$mail->smtpsecure = ' TLS ';//Enable encryption, ' SSL ' also accepted$mail->from = ' [email protected] ';$mail->fromname = ' Mailer ';$mail->addaddress (' [email protected] ', ' Joe User ');//Add a recipient$mail->addaddress (' [email protected] ');//Name is optional$mail->addreplyto (' [email protected] ', ' information ');$mail->ADDCC (' [email protected] ');$mail->ADDBCC (' [email protected] ');$mail-WordWrap= 50;//Set word wrap to characters$mail->addattachment ('/var/tmp/file.tar.gz ');//ADD Attachments$mail->addattachment ('/tmp/image.jpg ', ' new.jpg ');//Optional name$mail->ishtml (true);//Set Email format to HTML$mail->subject = ' Here is the Subject ';$mail->body = ' This is the HTML message Body <b>in bold!</b> ';$mail->altbody = ' The body in plain text for non-html mail clients ';if(!$mail-Send ()) { Echo' Message could not being sent. '; Echo' Mailer Error: '.$mail-ErrorInfo;} Else { Echo' Message has been sent ';}
A phpmailerautoload.php is introduced and instantiated to get a $mail object.
QQ Mailbox looked at a bit, so decided to use SMTP as an example to send mail, so $mail->issmtp ();
Next, follow the example step-by-step to configure the sender action:
$mail->host = ' smtp.qq.com ';
$mail->smtpauth = true; $mail->username = ' test [email protected] ';
$mail->password = ' test qq password ';
$mail->smtpsecure = ' TLS ';
Configure the recipient information, here can use an HTML form, here do not add, just watch and learn, and then do the next time you use to continue. Well, every day to learn a little new knowledge, memory is also a kind of learning, can not waste time, until the end to find that they saved their own, refueling. Let's go here for the time being. This article original blog address: http://www.cnblogs.com/unofficial official website address:www.pushself.com)