This article introduces the simple usage of the phpmailer email class, a simple example of the phpmailer class, and serves as an introductory reference for the phpmailer class library. Friends who need it can take a look.
In PHP programming, you often need to send emails, such as email reminders for user registration, etc. You can use a good open source module: phpmailer. This module has comprehensive functions and supports SMTP verification. How to use: 1. Download the phpmailer module: Official website http://www.phpdoc.org/ 2. Unzip to a folder 3, include require_once("class.phpmailer.php"); in the php file4. Use smtp to send emails (example of sending emails with phpmailer): $mail = new PHPMailer(); //得到一个PHPMailer实例 $mail->CharSet = "gb2312"; //设置采用gb2312中文编码 $mail->IsSMTP(); //设置采用SMTP方式发送邮件 $mail->Host = "192.168.1.27"; //设置邮件服务器的地址 $mail->Port = 25; //设置邮件服务器的端口,默认为25 $mail->From = "mailFrom@tencent.com"; //设置发件人的邮箱地址 $mail->FromName = "samzhang"; //设置发件人的姓名 //$mail->SMTPAuth = true; //设置SMTP是否需要密码验证,true表示需要 $mail->Username="samzhang"; $mail->Password = 'your password"; $mail->Subject = $subject; //设置邮件的标题 $mail->AltBody = "text/html"; // optional, comment out and test $mail->Body = "你的邮件的内容"; $mail->IsHTML(true); //设置内容是否为html类型 //$mail->WordWrap = 50; //设置每行的字符数 $mail->AddReplyTo("samzhang@tencent.com","samzhang"); //设置回复的收件人的地址 $mail->AddAddress("mailTo@tencent.com","toName"); //设置收件的地址 if(!$mail->Send()) { //发送邮件 echo 发送失败:'; } else { echo "发送成功; Copy after login |