Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a development Ubuntu Server (12.04.1) VM that I use to develop php sites and e-commerce sites (like Magento etc).

Because this is for development purposes, and I need to test with e-mail addresses other than my own, I need a way for the sendmail command to accept a mail but not actually deliver it, but rather archive is somewhere where I can look at it.

What is the easiest way to install a mail server such that the sendmail command routes ALL mail to a local directory? i.e. I do NOT want any mail to be delivered to the internet.

I tried the steps discussed in this question ( SMTP server to deliver ALL mail to user@localhost), but it doesn't seem to work - I get an error message in my (local) mailbox telling me that it cannot deliver my test message (e.g. someone@gmail.com)

share|improve this question

1 Answer

To answer my own question, using postfix this is possible. You have to do two things:

  1. Add the configuration options discussed in SMTP server to deliver ALL mail to user@localhost, add the following to your /etc/postfix/main.cf file:

    luser_relay = MYLOCALUSER@localhost
    local_recipient_maps =
    
  2. Using the following answer on serverfault ( http://serverfault.com/questions/133190/host-wildcard-subdomains-using-postfix), I added the following (note that you need the postfix-pcre package installed):

    In /etc/postfix/main.cf:

     mydestination = pcre:/etc/postfix/mydestinations
    

    In /etc/postfix/mydestinations

    /.*/         ACCEPT
    

This will deliver ALL mail that postfix handles to the configured local user defined in #1, so don't use this for anything other than development.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.