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!