【发布时间】:2017-06-16 03:50:46
【问题描述】:
我有以下代码来测试网站是否可以通过php发送邮件:
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "emailtest@YOURDOMAIN";
$to = "YOUREMAILADDRESS";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
?>
我已将此 php 文件上传到 www.mywebsite.com/data/iq/testing-email.php
当我运行脚本时出现以下错误:
警告:mail():无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置,或使用 C:\mywebsite.com\data\ 中的 ini_set() iq\test-email.php 在第 9 行
我的问题是为什么网站已经上线时显示 C:\ 文件目录的错误?
作为参考,此网站在 Microsoft IIS 服务器上运行,并且有 SSL,如果这有什么不同的话。
【问题讨论】:
标签: php email error-handling