php 实现邮件自动发送之 PHPMailer
一、拥有自己的邮箱账号,
二、开启客户端授权码 (需要使用的密码就是,开启邮箱客户端授权后设置的密码。)
三、PHPMailer的下载
邮件发送代码如下:
require 'PHPMailerAutoload.php'; //加载需要使用的类, 或者使用:include("class.phpmailer.php"); include("class.smtp.php");
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com'; // Specify main and backup SMTP servers 设置邮箱服务器,根据自己邮箱的类型而不同,比如163邮箱: $mail->Host = "smtp.163.com";
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username 你自己的邮箱账号
$mail->Password = 'secret'; /

本文介绍了如何利用PHPMailer库实现网页表单内容的自动发送到指定邮箱,包括准备邮箱账号、启用客户端授权码以及展示PHPMailer的邮件发送代码。
最低0.47元/天 解锁文章
1619

被折叠的 条评论
为什么被折叠?



