Send mail from localhost with PHP with MAMP
Asked Answered
K

7

6

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

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

Kaye answered 6/8, 2012 at 1:7 Comment(4)
MAMP - so you're on a mac? Probably won't have the actual sendmail, but may have postfix or exim, both of which provide a sendmail alias and masquerade as sendmail.Iq
Yeah, I'm on a Mac, and okay I'll see about those thanks.Kaye
possible duplicate of sending an email using MAMP and php scriptsSawdust
I know this post is 2 years old, but for what it's worth: the usr folder is a hidden one. See this post to show hidden folders in Finder: macworld.co.uk/how-to/mac-software/…Samirasamisen
K
2

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/

Kaye answered 6/8, 2012 at 1:53 Comment(1)
First time I see a validated answer with negative votes o_0Grecian
S
6

The solution on this post finally worked for me. https://tripleroi.com/solvedenabling-sendmail-on-localhost-for-mamp-free-version/

Correct setting in 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.

Sufferable answered 9/8, 2016 at 3:40 Comment(4)
Link no longer works, can you provide a code example.Rickets
Get ready to get a hell of a load of emails from the past, which were all stored and never sent until you change this :).Bartell
This solution still works in July 2022 with latest Mamp 6.6 and php 8.1.1Glyptic
March 2024, MAMP now includes MailHog. I answered this question using MailHog.Newspaper
K
2

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/

Kaye answered 6/8, 2012 at 1:53 Comment(1)
First time I see a validated answer with negative votes o_0Grecian
V
1

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.

Virology answered 10/6, 2013 at 11:18 Comment(0)
M
1

This is slightly off-topic, but you should know that if you're sending emails to any sort of real customers from the localhost, they're very likely to end up in spam. Instead of using a local email server, use one of the third-party, super-cheap email sending services: Amazon SES or Sendgrid are both easy to get started with, and easy to scale up with.

Metachromatism answered 10/7, 2021 at 23:37 Comment(0)
D
0

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.

Dolliedolloff answered 29/12, 2018 at 9:15 Comment(0)
N
0

MAMP has changed since this question was asked, and now includes MailHog, which makes it much easier to test emails.

Environment: MAMP is version 6.8.1, and I am on a Mac.

The MAMP php.ini file for my MAMP includes

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
MAMP_MailHog_MAMPsendmail_path = MAMP_mhsendmail_MAMP

Comment out the default mailing configuration so MailHog will be used:

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
  1. Download and install MailHog
  2. Edit /private/etc/postfix/main.cf to include:
myhostname = localhost
relayhost = [127.0.0.1]:1025
  1. View your local email by browsing to http://localhost:8025/

MAMP's own documentation on this: https://documentation.mamp.info/en/MAMP-PRO-Mac/Servers-and-Services/MailHog/

Newspaper answered 23/3, 2024 at 12:18 Comment(0)
I
-5

Set 'from' in mail.php config file.

Ineligible answered 2/8, 2015 at 10:38 Comment(1)
You may only send mails from emails attached to your domain... On localhost you don't have such an emailLaguna

© 2022 - 2025 — McMap. All rights reserved.