SMTP服务器响应:530 5.7.0必须首先发出STARTTLS命令。 Windows 7的

问题描述 投票:2回答:1

好吧,我正在使用Windows 7,我试图在php中发送带有mail()函数的电子邮件。我写了很多,但仍然无法发送。这是我的代码:

 ini_set("SMTP","smtp.gmail.com");
ini_set("smtp_port","25");


$to = '[email protected]';
$subject = 'hi';
$msg = 'Test';
$headers ='Reply-To: [email protected]' . "\r\n" .
        'From: postmaster@localhost' ."\r\n" .
        'X-Mailer: PHP /' . phpversion();
mail($to, $subject,$msg,$headers);

我得到:

  SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. x42sm11770579eel.41 - gsmtp

我尝试使用端口587,但后来我得到了:

    SMTP server response: 530 5.7.0 Must issue a STARTTLS command first.      y51sm11859758eeu.0 

请帮助我的页面端口465甚至不加载。我再次使用Windows 7。

php email send
1个回答
0
投票

使用像Swiftmailer这样的库来为你处理这个问题:http://swiftmailer.org/docs/sending.html

© www.soinside.com 2019 - 2024. All rights reserved.