简体   繁体   English

使用 PHP/IIS 发送电子邮件

[英]Send email with PHP/IIS

We're struggling with email submission via PHP.我们正在努力通过 PHP 提交电子邮件。 Currently we're using the following code:目前我们正在使用以下代码:

<?php 
 ini_set('display_errors',1);
 ini_set("SMTP","smtp.gmail.com");
 ini_set("smtp_port","587");
 ini_set("auth_username","mymail_address@gmail.com");
 ini_set("auth_password","mypassword");
 

 $to      = 'mydestination_address@gmail.com';
 $subject = 'the subject';
 $message = 'hello';
 $headers = 'From: mymail_address@gmail.com';

 if(mail($to, $subject, $message, $headers))
 {
    echo "Success!";
 }else
 {
    echo "Failed.";
 }
?>

The outcome of the code gives the following message:代码的结果给出了以下消息:

Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first.警告:mail():SMTP 服务器响应:530 5.7.0 必须首先发出 STARTTLS 命令。 e22sm16110599edu.35 - gsmtp in C:\\inetpub\\production\\mailtest.php on line 13 failed. e22sm16110599edu.35 - 第 13 行 C:\\inetpub\\production\\mailtest.php 中的 gsmtp 失败。

Please note that our application has been created with PHP using IIS.请注意,我们的应用程序是使用 IIS 使用 PHP 创建的。

I think you can do it with:我认为你可以这样做:

ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");

Please check if your PHP installation has SSL support before use the code above.在使用上面的代码之前,请检查您的 PHP 安装是否支持 SSL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM