1 回答
TA贡献1804条经验 获得超8个赞
请确保您在顶部添加 Phpmailer 类。
这是一个正常工作的邮件程序文件,将您的凭据放在这里并发送电子邮件。
<!DOCTYPE html>
<html>
<head>
<title>Php Mailer</title>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
</head>
<body>
<?php
// require 'PHPMailerAutoload.php';
require("PHPMailer-master/src/PHPMailer.php");
require("PHPMailer-master/src/SMTP.php");
require("PHPMailer-master/src/Exception.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$SendMailTo = "jonipk28@gmail.com";
$mail->SMTPDebug = 0;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com;'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = "your_user_name_or_email@gmail.com"; // SMTP username
$mail->Password = "your_user_Password"; // SMTP password
// $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom("your_user_name_or_email@gmail.com");
$mail->addAddress($SendMailTo); // Add a recipient // Name is optional
$mail->addReplyTo("your_user_name_or_email@gmail.com");
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
///send custom code in email
$code = 242343;
$mail->Subject = 'TeachMe verification email';
$mail->Body = 'Hi <br><br> <b>Thanks for registeration,Your verification code is </b>'.$code;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
</body>
</html>
- 1 回答
- 0 关注
- 71 浏览
添加回答
举报