Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup an SMTP server on Mac OS X?

I work with PHP and I have mamp on my machine. I would like to send emails within my PHP code:

<?php
 $to = "[email protected]";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 if (mail($to, $subject, $body)) {
   echo("<p>Message successfully sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
 ?>

How can I configure a mail server for free on my mac machine ?

like image 820
0x90 Avatar asked Jun 24 '12 03:06

0x90


2 Answers

Option 1:

CommandLineFu had this one liner to run an SMTP server on port 25:

sudo python -m smtpd -n -c DebuggingServer localhost:25

This will run a fake smtp server on your local machine. It won't send anything, but will dump it to the console.

Option 2:

Incase, you are not comfortable with command line then FakeSMTP is a Free Fake SMTP Server with GUI for testing emails in applications easily. It is written in Java. It is very nice and easy to use.

[http://nilhcem.com/FakeSMTP/][1]

like image 79
Devender Goyal Avatar answered Oct 31 '22 03:10

Devender Goyal


The following did the job. See source here.

  1. Edit file: sudo emacs /System/Library/LaunchDaemons/org.postfix.master.plist.
  2. Add <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> before the closing </dict> tag.
  3. Run sudo postfix start.

Check that SMPT is running: telnet localhost 25

like image 44
AlikElzin-kilaka Avatar answered Oct 31 '22 05:10

AlikElzin-kilaka