Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active January 16, 2023 10:22
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save zulhfreelancer/4663d11e413c76c6393fc135f72a52ce to your computer and use it in GitHub Desktop.
Save zulhfreelancer/4663d11e413c76c6393fc135f72a52ce to your computer and use it in GitHub Desktop.
How to send e-mail on Mac using MAMP (not PRO version) and Hotmail SMTP

How to send e-mail on Mac using MAMP (not PRO version) and Hotmail SMTP

Requirements

  1. A Mac running OSX 10.11.6
  2. MAMP v3.5
  3. PHP 7.0.0 (comes inside the MAMP v3.5 above)

Note

You'll see a lot of warnings in your Terminal throughout this process. That's normal.

Step 1

sudo nano /etc/postfix/main.cf

Step 2

Add this at the end of the file:

myorigin = live.com
myhostname = smtp.live.com
relayhost = smtp.live.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
inet_protocols = ipv4
smtp_use_tls = yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

Step 3

sudo nano /private/etc/postfix/master.cf

Step 4

Uncomment this line (remove the #)

tlsmgr  unix –       –       n       –       1000?       tlsmgr

Step 5

sudo nano /etc/postfix/sasl_passwd

Step 6

Add this line to it:

smtp.live.com:587 your_hotmail_username@hotmail.com:your_hotmail_password

Step 7

Run the following commands in Terminal, one by one:

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master
sudo postfix upgrade-configuration
sudo postfix reload
sudo postfix flush

Step 8

nano /Applications/MAMP/conf/php[version.you.use]/php.ini

Step 9

Find this section:

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

; For Win32 only.
; sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; sendmail_path =

And replace with:

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

; For Win32 only.
; sendmail_from = me@example.com

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

Step 10

To test, send an e-mail from Terminal using this command:

date | mail -s test your_another_email@example.com

It will take few seconds before you will the email.

Step 11

Re-start your MAMP server and try to run the PHP mail() script. It should work.

References

@ldco2016
Copy link

ldco2016 commented May 3, 2017

Hey I tried following this but I am getting this error:

danales-MacBook-Pro:Projects danale$ sudo postfix reload postfix: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all /usr/sbin/postconf: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all postfix/postlog: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all postfix/postfix-script: fatal: the Postfix mail system is not running danales-MacBook-Pro:Projects danale$ sudo postfix flush postfix: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all /usr/sbin/postconf: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all postqueue: warning: /etc/postfix/main.cf, line 696: overriding earlier entry: inet_protocols=all postqueue: fatal: Cannot flush mail queue - mail system is down danales-MacBook-Pro:Projects danale$

@Beber31
Copy link

Beber31 commented Oct 23, 2017

Hi ,
Interesting to parse all files . I'm on MAMP PRO and this has not worked for me ;(
Have differents Fatal errors and after plenty of tentatives in adressing different emails servers , I have succeeded to make my Postfix Up and running , Mailq was giving my list of Mails, and Postsuper was deleting some, but very strange is that after 15-30 seconds, my Server Postfix was falling down . I don't explain why . I don't know where are the logs ????
Could you help to find why the POSTFIX is falling down ?

@bhavyajain2024
Copy link

Will these steps work for me If I am at Mac OS version 11.4 and PHP version 7.4.12 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment