PHPMailer sends an email, phpmailer

Source: Internet
Author: User

PHPMailer sends an email, phpmailer

PHPMailer is an encapsulated PHP mail sending class that supports sending HTML content emails and image attachments. You must set up the mail server to enable the mail sending function.

HTML

First, place an inbox input box and a send email button:

Recipient:

<Input type = "text" class = "input_text" id = "email" name = "email" value = "@"/> <input type = "button" class = "btn "id =" send "value =" send "/> jQuery $ (function () {$ ("# send "). click (function () {var email = $ ("# email "). val (); $ ("# send "). addClass ("loading "). val ("loading... "). attr ("disabled", "disabled"); $. post ("ajax. php ", {" email ": email}, function (data) {if (data = 1) {$ (" # result "Success .html (" sent successfully, check your email! ");} Else {$ (" # result ").html (data) ;}$ (" # send "). removeAttr ("disabled "). removeClass ("loading "). val ("send ");});});});
Ajax. phprequire_once ('class. phpmailer. php '); $ address = $ _ POST ['email']; // recipient email $ mail = new PHPMailer (); // instantiate $ mail-> IsSMTP (); // enable SMTP $ mail-> Host = "smtp.163.com"; // The SMTP server uses the 163 email address as an example. $ mail-> Port = 25; // mail sending port $ mail-> SMTPAuth = true; // enable SMTP authentication $ mail-> CharSet = "UTF-8 "; // character set $ mail-> Encoding = "64"; // Encoding method $ email_system = "hjl416148489_3@163.com"; $ mail-> Username = $ email_system; // your email address $ mail-> Pa Ssword = ""; // your password $ mail-> Subject = "hello"; // email title $ mail-> From = $ email_system; // sender address (that is, your email address) $ mail-> FromName = ""; // sender name $ mail-> AddAddress ($ address, ""); // Add the recipient (address, nickname) $ mail-> AddAttachment('send.xls ', 'My attachment .xls'); // Add the attachment and specify the name $ mail-> IsHTML (true ); // supports html content $ mail-> Add dedImage ("logo.jpg", "my-attach", "logo.jpg "); // set the image $ mail-> Body = 'hello, <B> friend </B> in the email! <Br/> This is an email from <a href = "http://www.erdangjiade.com" target = "_ blank"> erdangjiade.com </a>! <Br/>  '; // body content of the email // send if (! $ Mail-> Send () {echo "failed to Send:". $ mail-> ErrorInfo;} else {echo "1 ";}

The above is a small Editor to introduce PHPMailer to send an email, hope to help you, if you have any questions, please leave a message, the small editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.