Send & Receive mails to & from localhost

Mails don’t work when locally but sometimes it might prove to be very useful in development if one can send & receive mails to & from localhost. It can be setup pretty easily too. Basic idea is to configure postfix for localhost & then use mutt to read local mails. Here is how it is done (should work fine for any UNIX based OS):

Install postfix

sudo apt-get install postfix

Install mutt

sudo apt-get install mutt

To configure postfix for localhost, specify the following in its config file at /etc/postfix/main.cf

myorigin = localhost
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
relayhost =

Restart postfix

sudo /etc/init.d/postfix restart

Now you can read localhost mails using mutt

mutt

It will read emails from /var/mail/USERNAME


Comments

4 responses to “Send & Receive mails to & from localhost”

  1. Hi ASHFAME,
    i have gone through your article.good article.
    Is it works on windows platform?

    1. Sorry! Only for unix based OS – linux / MAC

  2. Nice tutorial. Will this work if using MAMP on mac?

    1. Should work just fine.

Leave a Reply

Your email address will not be published. Required fields are marked *