Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test PHP send mail on local server with MAMP Pro

I have a small web form that on submission triggers a mail script that sends an email to the address given to verify their email address.

I want to test this on my local server using MAMP Pro. I am totally confused from the info I have sourced that holds different advice and requirements.

I use Dreamweaver (DW) with WebAssist (WA) extensions to build my PHP scripts and when I contacted WA support to ask how to enter the correct settings with their DW plugin to work with MAMP pro they told me..

To have your localhost send email you need to install a local SMTP server configured for email relay.

If you want to use a remote smtp server you would likely have to use the PEAR mail option for authentication.

This has thrown me as I can't see anywhere in any MAMP Pro documentation about having to install SMTP servers and I know nothing about PEARL.

The following Blog makes it sound simple..

http://blog-en.mamp.info/2009/09/how-to-sending-emails-with-mamp-pro.html

But it obviously isn't as I have tried these Postfix settings with know joy.

I have also seen this post..

Test emails locally with mamp

..that gives a method using gmail but I just can't make sense of it as It appears that the MAMP interface may have changed since this was written.

Plus I am not familiar with using Terminal.

If anyone can shed some light on this to point me in the right direction I would be most greatfull

like image 425
Steve Joiner Avatar asked Sep 01 '17 09:09

Steve Joiner


1 Answers

You can use Mailhog to achieve this. I wrote a tutorial on Medium.

Install mailhog using Homebrew (if you don't have Homebrew installed, check out the instructions here: https://brew.sh/):

brew install mailhog

Open MAMP Pro and go to the “Postfix” tab. Make sure the checkbox next to “Include Postfix service in GroupStart” is checked. Use these setting for Postfix:

  1. Fill in your domain name in the field “Set domain of outgoing e-mails to:”
  2. Check “Use a Smart host for routing”
  3. “Server name:” is 127.0.0.1:1025 (this is the SMTP port Mailhog uses)
  4. Set “Authentication” to “none”

Go to http://127.0.0.1:8025/ in your browser to see the mails sent by PHP.

like image 167
janhenkes Avatar answered Sep 27 '22 22:09

janhenkes