dpn68721 2013-03-07 01: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 01: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部