任何人都可以帮我看看哪个部分我错了...因为我问我的托管服务提供商也没有人想帮忙...我已经花了一整天的时间用这个SMTP并尝试了很多不同的代码来自互联网但是仍然无法发出一封简单的电子邮件......任何人都会... ...
require 'PHPMailerAutoload.php';
require 'class.smtp.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 1; // Enable verbose debug output
$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 = 'maxsmtp88@gmail.com'; // SMTP username
$mail->Password = 'emailpasswordhere'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = 'maxsmtp88@gmail.com';
$mail->FromName = 'Max';
$mail->addAddress('maxsmtp88@gmail.com', 'Max'); // Add a recipient
$mail->addReplyTo('maxsmtp88@gmail.com', 'Max');
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$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';
}
我真的不明白这个SMTP正在帮助托管服务提供商防止在垃圾邮件上出现不良声誉他们为什么不想帮助我...
答案 0 :(得分:0)
尝试将端口号更改为587,并在您的Gmail帐户设置中,允许访问不太安全的应用。