<?php require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录 $mail = new PHPMailer(); //建立邮件发送类 $address = "接收方邮箱"; //接收方地址 $mail->IsSMTP(); //使用SMTP方式发送 $mail->Host = "发送者邮箱smtp"; //您的企业邮局域名 $mail->SMTPAuth = true; //启用SMTP验证功能 $mail->Username = "发送者邮箱用户名";//邮局用户名(请填写完整的email地址) $mail->Password = "发送者邮箱密码"; //邮局密码 $mail->From = "发送者邮箱地址"; //邮件发送者email地址 $mail->FromName = "发送者昵称"; $mail->AddAddress("$address", "");//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名") $mail->Subject = "邮箱标题"; //邮件标题 $mail->Body = "邮件内容"; //邮件内容 $mail->AltBody = "---来自Apple Watch客户端"; //附加信息,可以省略 if(!$mail->Send()) { echo "<script>alert(‘邮件发送失败!‘)</script>"; echo "错误原因: " . $mail->ErrorInfo; exit(); } else echo "<script>alert(‘密码已发送至你的注册邮箱,请注意查收!‘)</script>"; ?>
时间: 2024-10-05 04:58:29