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

Published by

Ashfame

Developer + Entrepreneur + Opensource fanatic. Love WordPress + Startups + Music + Adrenaline kick.

  • http://www.androidevents.com/ chiru

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

    • http://www.ashfame.com Ashfame

      Sorry! Only for unix based OS – linux / MAC

  • http://danielpaul.me/ Daniel

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

    • http://www.ashfame.com Ashfame

      Should work just fine.