Phpmailer sends mail instance code header (quot; Content-type: texthtml; charsetutf-8quot;); include (#39; ph...
Phpmailer email sending instance code
Header ("Content-type: text/html; charset = utf-8"); include ('phpmailer/class. phpmailer. php '); include ('phpmailer/class. smtp. php '); $ mail = new PHPMailer (); $ mail-> IsSMTP (); // set mailer to use SMTP $ mail-> Host = "smtp.sohu.com "; // SMTP server $ mail-> Port = 25; $ mail-> SMTPAuth = true; // SMTP Authentication? $ Mail-> Username = "yourmail@sohu.com"; // Username $ mail-> Password = "yourmail168"; // Password $ mail-> From = "spr_zsql@163.com "; // sender address $ mail-> FromName = "test"; // sender $ mail-> AddAddress ("yourmail@qq.com", "test"); // recipient address, recipient name $ mail-> WordWrap = 50; // $ mail-> AddAttachment ("/var/tmp/file.tar.gz "); // attachment // $ mail-> AddAttachment ("/tmp/image.jpg", "new.jpg"); // attachment, new file name $ mail-> IsHTML (true ); // HTML format $ mail-> Sub Ject = "test"; $ mail-> Body = "test"; if (! $ Mail-> Send () {echo "Mailer Error:". $ mail-> ErrorInfo; echo "email sending Error! ";} Else {echo" email sent successfully! ";}
Permanent link:
Reprint at will! Include the article address.