From a question of the answer to self-reflection how does php send mail? Send mail plugin Phpmailer

Source: Internet
Author: User
Tags html form php send email php send mail word wrap

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-&GT;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-&GT;ADDCC (' [email protected] ');$mail-&GT;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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.