一.首先下载phpmailer
https://github.com/chenlian2015/phpmailer.git
二.将下载所得目录中的
class.phpmailer.php
立即学习“PHP免费学习笔记(深入)”;
class.smtp.php
两个文件拷贝到你的工程目录下
Serendipity是一个采用PHP实现的智能博客BLOG系统,Serendipity功能丰富,符合标准,基于BSDLicense开源。 Serendipity 2.1.3 更新日志:2018-08-16 *安全性:确保RSS的管理员配置和博客条目限制被解析为SQL查询的整数; *安全性:在“编辑条目”面板中防止XSS可能性; *安全性:禁止向多个人发送评论通知和邮件地址;这可用于批
93
三.使用
<?phpfunction postmail($to,$subject = '',$body = ''){ //Author:Jiucool WebSite: http://www.jiucool.com //$to 表示收件人地址 $subject 表示邮件标题 $body表示邮件正文 //error_reporting(E_ALL); echo "enter"; error_reporting(E_STRICT); date_default_timezone_set('Asia/Shanghai');//设定时区东八区 require_once('class.phpmailer.php'); include('class.smtp.php'); echo "enterx"; $mail = new PHPMailer(); //new一个PHPMailer对象出来 $body = eregi_replace("[\]",'',$body); //对邮件内容进行必要的过滤 $mail->CharSet ="GBK";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 1; // 启用SMTP调试功能 // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // 启用 SMTP 验证功能 //$mail->SMTPSecure = "ssl"; // 安全协议,可以注释掉 $mail->Host = 'smtp.126.com'; // SMTP 服务器 $mail->Port = 25; // SMTP服务器的端口号 $mail->Username = '这里写你的126邮箱'; // SMTP服务器用户名,PS:我乱打的 $mail->Password = '这里写你的密码'; // SMTP服务器密码 $mail->SetFrom('这里写你的126邮箱', 'who'); $mail->AddReplyTo('这里写你要发送的目的邮箱','name'); $mail->Subject = $subject; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional, comment out and test $mail->MsgHTML($body); $address = $to; $mail->AddAddress($address, ''); $mail->AddAttachment("windows.pdf"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo "Message sent!恭喜,邮件发送成功!"; }} postmail('这里写你要发送的目的邮箱','My subject','哗啦啦');?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号