macos PHP mail() 在 Mac OS X Leopard (10.5.8) 上使用 Sendmail

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2450589/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:49:03  来源:igfitidea点击:

PHP mail() using Sendmail on Mac OS X Leopard (10.5.8)

phpmacosemailsendmailosx-leopard

提问by paperclip

I've been struggling to get a really basic PHP function working on my iMac, the PHP mail()function.

我一直在努力让一个真正基本的 PHP 函数在我的 iMac 上运行,即 PHPmail()函数。

I've used it countless times, albeit on a Windows platform and now I'm trying to get it running on Mac.

我已经无数次使用它了,尽管是在 Windows 平台上,现在我正试图让它在 Mac 上运行。

I've installed XAMPP v1.01 maybe because I didn't know any better at the time and I thought it would all just work fine, because that's what it's supposed to do. (Or so I thought).

我安装了 XAMPP v1.01 可能是因为我当时不知道有什么更好的,我认为它会正常工作,因为这就是它应该做的。(或者我是这么认为的)。

I've tried the following pages of instructions to no avail:

我已经尝试了以下页面的说明无济于事:

To start with I did not have an entry for: MAILSERVER=-YES-in my /etc/hostconfigso I created it.

首先,我MAILSERVER=-YES-/etc/hostconfig 中没有以下条目: 所以我创建了它。

I added the full path to sendmail in my php.ini: sendmail_path = "/usr/sbin/sendmail -t -i"

我在php.ini 中添加了 sendmail 的完整路径:sendmail_path = "/usr/sbin/sendmail -t -i"

I understand I don't need to set a myhostnamevariable in /etc/postfix/main.cfbecause I'm only planning on sending mail not receiving it. (NB. I've also tried it with this setting enabled!)

我知道我不需要myhostname/etc/postfix/main.cf 中设置变量,因为我只打算发送邮件而不接收它。(注意。我也尝试过启用此设置!)

I've start postfix and then tried running the script but the script just processes with no error message, it just basically constantly looks as if it's working but nothing happens (I've triple checked the code for script).

我已经启动了 postfix,然后尝试运行脚本,但脚本只是在处理,没有错误消息,它基本上一直看起来好像在工作,但没有任何反应(我已经三次检查了脚本的代码)。

I noticed some peoples solutions do not even mention having to start the postfix daemon for them to get the PHP mail()function to work.

我注意到有些人的解决方案甚至没有提到必须为他们启动 postfix 守护程序才能使 PHPmail()函数正常工作。

Any ideas or things for me to try?

有什么想法或事情让我尝试吗?

If you need more info, please ask.

如果您需要更多信息,请询问。

P.

P。

采纳答案by audiodude

Pasting in an answer from here: http://macosx.com/forums/unix-x11/19819-sendmail-not-working.html

从这里粘贴答案:http: //macosx.com/forums/unix-x11/19819-sendmail-not-working.html

Sounds like your problem based on the log entries you posted.

根据您发布的日志条目,这听起来像是您的问题。

Additionally, the author of that post recommends that you'll have to do this again after a system update, so "repair permissions" is NOT what you want....and possibly the OPPOSITE of what you want.

此外,该帖子的作者建议您在系统更新后必须再次执行此操作,因此“修复权限”不是您想要的......而且可能与您想要的相反。

The most common problem with sendmail on OS X is just a permission problem, and one which will show up after installing most packages from Software Update. Check /var/log/mail.log and see if it's complaining a lot about a group writable directory. If that's the case, then the problem is that the root directory is group writable. That's easily fixed with a quick "sudo chmod g-x /". Then sendmail should be able to start properly, and I think it can be invoked by typing "/usr/sbin/sendmail -bd -q1h". Again, if all else fails, reboot.

在 OS X 上使用 sendmail 最常见的问题只是权限问题,并且会在从软件更新安装大多数软件包后出现。检查 /var/log/mail.log 并查看它是否对组可写目录抱怨很多。如果是这种情况,那么问题在于根目录是组可写的。这可以通过快速的“sudo chmod gx /”轻松解决。那么sendmail应该就可以正常启动了,我觉得输入“/usr/sbin/sendmail -bd -q1h”就可以调用了。同样,如果所有其他方法都失败了,请重新启动。

回答by Daniel Tedman

XAMPP uses its own /etc folder, it is contained within the applications bundle. You right click and select show package contents. Now follow the guides you have listed but apply the changes to this /etc folder not the macs /etc folder.

XAMPP 使用自己的 /etc 文件夹,它包含在应用程序包中。您右键单击并选择显示包内容。现在按照您列出的指南进行操作,但将更改应用于此 /etc 文件夹而不是 macs /etc 文件夹。