我想用php发送邮件我的代码就是这些;
<?php
include 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = 'mertcankarayilan@gmail.com';
$mail->Password = '*******';
$mail->SetFrom($mail->Username, 'Pegasus Havayolları?');
$mail->AddAddress('mertcankarayilan@hotmail.com', 'mertcankarayilan');
$mail->CharSet = 'UTF-8';
$mail->Subject = 'Ekomak';
$content = 'mailde yazan';
$mail->MsgHTML($content);
if($mail->Send()) {
echo "<script>window.location.href='islem-basari.php#gosterb';</script>";
} else {
echo 'Mail gönderilirken bir hata oluştu: ' . $mail->ErrorInfo;
}
?>
我看到这样的错误:
以下发件人地址失败:mertcankarayilan@gmail.com:不接受服务器邮件
SMTP服务器错误:5.7.0必须先发出STARTTLS命令。 k6sm56314517eep.17 - gsmtp
答案 0 :(得分:0)
您必须输入方法'TLS':
$mail->SMTPSecure = "tls";