Send mail using Phpmailer based (SMTP)

Source: Internet
Author: User
Tags email account

Phpmailer is a PHP function package that is used to send e-mail messages. Features include: Specify multiple recipients, CC address, send address and reply address, support for multiple message encodings including: 8bit,base64,binary and quoted-printable, support for SMTP authentication, Supports mail with attachments and HTML-formatted messages.

Implementation code:

<?PHPinclude' Class.smtp.php ';include' Class.phpmailer.php ';$mail=NewPhpmailer;$mail-&GT;ISSMTP ();//turn on the SMTP service$mail->host = ' smtp.xx.com ';//SMTP server addresses can use SMTP for each large mailbox and have detailed instructions$mail->smtp_port = 25;//SMTP Service port defaults to$mail->smtpauth =true;//turn on SMTP authentication$mail->username = ' [email protected] ';//Email Account$mail->password = ' ... ';//Email Password$mail->from = ' [email protected] ';//The Outbox should match the user name$mail->fromname = ' Mailer ';//Sender Salutation$mail->addaddress (' [email protected] ', ' salutation ');//recipient address and Salutation$mail-WordWrap= 50; //Add Attachment If welcome here Set//$mail->addattachment ('/tmp/image.jpg ', ' new.jpg ');$mail->ishtml (true);//use HTML-style messages$mail->subject = ' Here is the Subject ';//message Header$mail->body = ' This is the HTML message Body <b>in bold!</b> ';//Message Content$mail->altbody = ' The body in plain text for non-html mail clients ';//Email Alertsif(!$mail-Send ()) {    Echo' Message could not being sent. '; Echo' Mailer Error: '.$mail-ErrorInfo;} Else {    Echo' Message has been sent ';}?>

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.