Send mail from localhost with PHP with MAMP

2019-05-10 18:37发布

问题:

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 = myemail@yahoo.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -i -f myemail@yahoo.com

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?)

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)

Any help would be greatly appreciated, thanks!

(if there are any other ways, (easier ways) of doing this, please also let me know).

回答1:

The solution on this post finally worked for me. http://www.blog.tripleroi.com/2012/05/solvedenabling-sendmail-on-localhost.html

Correct setting in php.ini:

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = don@tripleroi.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path =/usr/sbin/sendmail -t -i -f  yourname@example.com

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.



回答2:

I used to have an array of problems like this including the email one when I was still using 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.

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.



回答3:

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/



回答4:

In my case the problem was in empty /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:

sudo cp main.cf~orig main.cf

After that MAMP starts sending mails.



回答5:

Set 'from' in mail.php config file.



标签: php email mamp