dp0518 2017-06-16 03:50
浏览 44
已采纳

PHP邮件错误报告

I have the following code to test if the website can send mail via 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";
?>

I have uploaded this php file to www.mywebsite.com/data/iq/testing-email.php

when I run the script I get the following error:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\mywebsite.com\data\iq\test-email.php on line 9

My question is why is the error showing a C:\ file directory when the website is already live?

For reference this website is running on a Microsoft IIS Server and has an SSL if that makes any difference.

  • 写回答

1条回答 默认 最新

  • doufan8805 2017-06-16 04:38
    关注

    When you use mail() your PHP script tries to connect to an external SMTP to deliver your email, so you must configure a valid one.

    By default it tries to connect to localhost, but the webserver apparently is not running an SMTP server, so you should ask your provider for the correct SMTP to use, and set it with:

    ini_set('SMTP','smtp.yourprovider.cxm');
    ini_set('smtp_port',25);
    

    About your second question, C:\mywebsite.com\ is probably the server folder where your files are hosted, so it looks very normal to me.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据