mail() [function.mail]: "sendmail_from" 未在我的 apache 服务器上的 php.ini 中设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19160444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mail() [function.mail]: "sendmail_from" not set in php.ini on my apache server
提问by Rhys Jones
Afternoon all, I recently set up my own local server doing apache, mysql and php individually as oppose to grabbing the available products out there such as WAMP and XAMPP. I've come across an issue when using the mail()
function in php though. That's this:
下午,我最近建立了自己的本地服务器,分别执行 apache、mysql 和 php,以反对获取可用的产品,例如 WAMP 和 XAMPP。不过,我mail()
在 php 中使用该函数时遇到了一个问题。就是这样:
mail() [function.mail]: "sendmail_from" not set in php.ini
I've tried going into the php.ini file as configuring it but have had no hope. It's come to my understanding that I'm going to need to set up my SMTP? However, I've no idea about how to do this and don't want to go ahead and try without having some knowledge on it first.
我试过进入 php.ini 文件进行配置,但没有希望。据我所知,我将需要设置我的 SMTP?但是,我不知道如何执行此操作,并且不想在没有先了解它的情况下继续尝试。
Can anyone give me some detailed step by step instructions please on how I can set this up so that my mail()
function in php works great within my local server?
谁能给我一些详细的分步说明,请告诉我如何设置它,以便我mail()
在 php 中的函数在我的本地服务器中运行良好?
Thanks in advance, Rhys
提前致谢,里斯
回答by Serge S.
You are missing From
header applied to your message.
您缺少From
应用于您的邮件的标题。
You could do it by specifying 4th parameters $headers
of mail()
function:
您可以通过指定函数的第 4 个参数$headers
来实现mail()
:
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]';
mail($to, $subject, $message, $headers);
回答by Ashwin Parmar
I thing you should download the sendmail utility for sending the mail and it will be very easy to configure.
我认为您应该下载用于发送邮件的 sendmail 实用程序,并且配置起来非常容易。
- download sendmail.zipand unzip its contents
- copy sendmail.exe and sendmail.ini to
\usr\lib
on the drive where the unix application is installed - eg. if your application is installed in
c:\bugzilla
,sendmail.exe
andsendmail.ini
need to be copied toc:\usr\lib\sendmail.exe
andc:\usr\lib\sendmail.ini
. configuresmtp server
and default domain in sendmail.ini
- 下载sendmail.zip并解压其内容
- 将 sendmail.exe 和 sendmail.ini 复制到
\usr\lib
安装了 unix 应用程序的驱动器上 - 例如。如果您的应用程序安装在
c:\bugzilla
,sendmail.exe
并且sendmail.ini
需要复制到c:\usr\lib\sendmail.exe
和c:\usr\lib\sendmail.ini
。smtp server
在 sendmail.ini 中配置和默认域
here sendmail.ini
in which you can configure your mail server settings and sending_from, replymail
everything in one file.
在这里sendmail.ini
,您可以sending_from, replymail
在一个文件中配置您的邮件服务器设置和所有内容。
I hope it is helpful.
我希望它有帮助。
回答by Rhys Jones
Thanks for the replies everyone. In the end, I figured out I was being silly in the config file for php using wrong syntax. I connected it up with my works SMTP server in the end, so all is good. Thanks for the responses.
谢谢大家的回复。最后,我发现我在 php 的配置文件中使用错误的语法是愚蠢的。最后我把它连接到我的工作 SMTP 服务器,所以一切都很好。感谢您的回复。