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 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题