Phpmailer is a powerful Mail sending class written in php. it can be used to send mails more conveniently and send attachments and HTML emails, you can also use the SMTP server to send emails. Phpmailer is a powerful Mail sending class written in php. it can be used to send mails more conveniently and send attachments and HTML emails, you can also use the SMTP server to send emails.
Although php has a mail () function, this mail function still has many limits in use and is rarely used in practical applications.
Phpmailer class File: Batch.
Example:
CharSet = 'utf-8'; // tell the class to use SMTP $ mail-> IsSMTP (); // enable SMTP authentication $ mail-> SMTPAuth = true; // set the SMTP server port $ mail-> Port = 465; // SMTP server $ mail-> Host = "smtp.163.com "; // SMTP server username $ mail-> Username = "example@163.com"; // SMTP server password $ mail-> Password = "password "; // tell the class to use Sendmail $ mail-> IsSendmail (); // Set the sender's email address and user name $ mail-> From = "Example@163.com"; $ mail-> FromName = "username"; // Set the email address $ mail-> AddReplyTo ("example@163.com "); // Set the recipient address $ mail-> AddAddress ('example @ gmail.com '); // mail Title $ mail-> Subject = "PHP sends an email via phpmailer "; // optional, comment out and test $ mail-> AltBody = "To view the message, please use an HTML compatible email viewer! "; // Set word wrap $ mail-> WordWrap = 80; $ content = 'php sends emails via phpmailer '; $ mail-> MsgHTML ($ content ); // send as HTML $ mail-> IsHTML (true); $ mail-> Send (); echo 'Message has been sent. ';} catch (phpmailerException $ e) {echo $ e-> errorMessage ();}
The above is a simple example of phpmailer. phpmailer has many other functions that need to be studied.