PHP:在本地主机发送邮件 [英] PHP : send mail in localhost

查看:128
本文介绍了PHP:在本地主机发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <?php 
$ email = myemail@local.com;
$ titre =我的主题;
$ message =短信!;
mail($ email,$ titre,$ message);
?>

当我运行此代码时,我收到以下错误:

 警告:mail()[< a href ='function.mail'> function.mail< / a>]:无法连接到邮件服务器& QUOT;本地主机&安培; QUOT;端口25,验证您的& quot; SMTP& quot;和& quot; smtp_port& quot;在php.ini中设置或在C:\ ... 

中使用ini_set() php.ini 文件,似乎已经配置良好。

  [邮件功能] 
;仅适用于Win32
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

我如何解决这个问题 ?



谢谢

解决方案

配置为使用 localhost:25 为邮件服务器。



错误信息表示无法连接到 localhost:25



所以你有两个选择:


  1. 安装/正确配置本地端口25上的SMTP服务器

  2. 将配置更改为指向您可以连接到的其他SMTP服务器 li>


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

解决方案

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

这篇关于PHP:在本地主机发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆