dpn68721 2013-03-07 09:27
浏览 65
已采纳

PHP:在localhost中发送邮件

I would like to send email through php code hosted locally.

<?php 
$email  = "myemail@local.com"; 
$titre   = "My subject"; 
$message = "Text message !"; 
mail($email, $titre, $message); 
?>

When I run this code, I get the following error :

Warning: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at &quot;localhost&quot; port 25, verify your &quot;SMTP&quot; and &quot;smtp_port&quot; setting in php.ini or use ini_set() in C:\...

I went into the php.ini file and it seems to be already well configured.

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

How can I fix this ?

Thank you

  • 写回答

4条回答 默认 最新

  • dty98339 2013-03-07 09:31
    关注

    It is configured to use localhost:25 for the mail server.

    The error message says that it can't connect to localhost:25.

    Therefore you have two options:

    1. Install / Properly configure an SMTP server on localhost port 25
    2. Change the configuration to point to some other SMTP server that you can connect to
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化