使用 PHP 和 MAMP 从本地主机发送邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11821486/
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
Send mail from localhost with PHP with MAMP
提问by Dylan Cross
I've been trying everything I can find on the internet for this, and none of them seem to be working, so I'm doing something wrong and I need some help figuring out what.
为此,我一直在尝试在互联网上可以找到的所有内容,但似乎没有一个有效,所以我做错了什么,我需要一些帮助来弄清楚是什么。
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]
The above code is what I have changed everything to, (except for the email is my actual email (also I'm not sure if yahoo email will work with this or not, so maybe that's the problem?)) I am not sure where the sendmail_path goes to, I cannot find that path anywhere (am I suppose to download some file/program called sendmail?)
上面的代码是我将所有内容更改为的内容(除了电子邮件是我的实际电子邮件(我也不确定雅虎电子邮件是否适用于此,所以也许这就是问题所在?))我不确定在哪里sendmail_path 转到,我在任何地方都找不到该路径(我是否想下载一些名为 sendmail 的文件/程序?)
also, my APACHE port I have changed to 80, and my MySQL port is 3306, (I don't know if those ports have anything to do with the smpt_port or not)
还有,我的APACHE端口我改成了80,我的MySQL端口是3306,(不知道这些端口和smpt_port有没有关系)
Any help would be greatly appreciated, thanks!
任何帮助将不胜感激,谢谢!
(if there are any other ways, (easier ways) of doing this, please also let me know).
(如果有任何其他方法,(更简单的方法)这样做,也请告诉我)。
采纳答案by Dylan Cross
MAMP PRO already has this, and has a simple interface to do this, I got it and I have it working perfectly. http://www.mamp.info/en/mamp-pro/
MAMP PRO 已经有了这个,并且有一个简单的界面来做到这一点,我得到了它并且我让它完美地工作。 http://www.mamp.info/en/mamp-pro/
回答by Federico
The solution on this post finally worked for me. http://www.blog.tripleroi.com/2012/05/solvedenabling-sendmail-on-localhost.html
这篇文章上的解决方案终于对我有用。 http://www.blog.tripleroi.com/2012/05/solvedenabling-sendmail-on-localhost.html
Correct setting in php.ini:
php.ini 中的正确设置:
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path =/usr/sbin/sendmail -t -i -f [email protected]
You have to make sure to comment out the Win32 settings. After doing that, my MAMP server on my Mac finally got a mail through.
您必须确保注释掉 Win32 设置。这样做之后,我的 Mac 上的 MAMP 服务器终于收到了一封邮件。
回答by bottleboot
I used to have an array of problems like this including the email one when I was still using MAMP.
我曾经遇到过一系列这样的问题,包括我还在使用 MAMP 时的电子邮件问题。
MAMP Pro should fix it all, but I recommend just doing an install of apache/php/mysql yourself. You'll have no more problems with basic stuff like this and it's a free solution.
MAMP Pro 应该可以解决所有问题,但我建议您自己安装 apache/php/mysql。像这样的基本东西不会再有问题,这是一个免费的解决方案。
If you're on OSX apache is already there, php can be installed via homebrew. Mysql can just be downloaded from the official site as an installer.
如果您使用的是 OSX apache,则可以通过homebrew安装 php 。Mysql 可以作为安装程序从官方网站下载。
回答by bigsiter
In my case the problem was in empty /etc/postafix/main.cf
在我的情况下,问题出在空的 /etc/postafix/main.cf
cat /etc/postafix/main.cf
shows nothing. But there was not empty main.cf~orig So I've hust copied contents from main.cf~orig:
什么都不显示。但是没有空的 main.cf~orig 所以我已经从 main.cf~orig 复制了内容:
sudo cp main.cf~orig main.cf
After that MAMP starts sending mails.
之后 MAMP 开始发送邮件。
回答by Morteza Sepehri Niya
Set 'from'in mail.phpconfig file.
'from'在mail.php配置文件中设置。

