2014-02-17 48 views
0

我想用PHP发送邮件我的代码是这些;发送邮件通过SMTP错误在PHP

<?php 
include 'class.phpmailer.php'; 
$mail = new PHPMailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth = true; 
$mail->Host = 'smtp.gmail.com'; 
$mail->Port = 587; 
$mail->Username = '[email protected]'; 
$mail->Password = '*******'; 
$mail->SetFrom($mail->Username, 'Pegasus Havayolları?'); 
$mail->AddAddress('[email protected]', '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; 
} 

?> 

,我看到这样的错误:

下面的发件人地址失败:[email protected]:邮件无法从服务器

SMTP server error: 5.7.0 Must issue a STARTTLS command first. k6sm56314517eep.17 - gsmtp

+0

可能重复的[SMTP服务器响应:530 5.7.0 M首先发出STARTTLS命令](http://stackoverflow.com/questions/5265692/smtp-server-response-530-5-7-0-must-issue-a-starttls-command-first) – Rikesh

+0

示例ho send电子邮件与smtp starttls和php流套接字 https://stackoverflow.com/questions/46974653/authentication-failure-smtp-starttls-failed-code-220-response-2-0-0-ready/47121000#47121000 – Max

回答

0

您必须输入法 'TLS' 接受:

$mail->SMTPSecure = "tls";