How to use Phpmailer to achieve mail delivery??

Source: Internet
Author: User
Tags set time

Source: http://www.ido321.com/1103.html

Sending mail is a feature that is frequently used. LZ also met today in the project, hereby share.

First of all. To download Phpmailer

1, Https://github.com/dwqs/PHPMailer

2, http://download.csdn.net/detail/u011043843/8063583

After the download. Unzip the files to the appropriate location in the project folder, introduce class.phpmailer.php and class.smtp.php into the project, see the Code: (Extract the files do not delete, otherwise not)

<?php//Necessary import  require("class.phpmailer.php");require("class.smtp.php"); Date_default_timezone_set (' Asia/shanghai ');//Set time zone East area eight$mail =NewPhpmailer ();//Set up a mail sending class$address ="[email protected]"; $mail->issmtp ();//Send using SMTP$mail->charset ="UTF-8";//Set the encoding. Otherwise send Chinese garbled$mail->host ="Smtp.qq.com";//Your enterprise Post office domain name$mail->smtpauth =true;//Enable SMTP Authentication feature$mail->username ="[email protected]";//Post Office username (please fill in the full email address)$mail->password ="**********";//Post office password$mail->from ="[email protected]";//Email sender email Address$mail->fromname ="Dwqs"; $mail->addaddress ($address,"Dwqs");//Recipient address, can be replaced by whatever email you want to receive mail, the format is addaddress ("Recipient Email", "Recipient name")//$mail->addreplyto ("", "");//$mail->addattachment ("/var/tmp/file.tar.gz");//Add Attachment//$mail->ishtml (TRUE);//Set email format to HTML//whether HTML is used$mail->subject ="Verify Mail";//Mail header$mail->body ="Hello, this is Test mail.";//email content$mail->altbody ="This was the body in plain text for non-html mail clients";//Additional information that can be omittedif(! $mail->send ()) {Echo ' Mailer Error: '.    $mail->errorinfo; }Else{Echo "Message sent! Congratulations, Mail sent successfully!"

"; }?

>

Test results:


watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmta0mzg0mw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

Next article: Your university. How many regrets?

How to use Phpmailer to achieve mail delivery??

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.