Apparently it's as simple as just sending an e-mail to a local account, and configuring Postfix to receive mail for the local account. Not too shabby!

Original Question

This hypothetic server would run Postfix on LAMP.

I have a contact form on a webpage, of which contents are sent with PHP mail() to the contact e-mail address.

Is there a way to just save the form contents as a mail directly to the server (using postfix) without actually sending it out of the server and receiving it again?

The reason I want to do it this way is because I want to use the user's e-mail address as the sender address, and this could be problematic wthout the correct configuration of headers and things, as far as I've come to understand in regards to blacklists etc. In addition to this, of course, it seems very redundant for the server to spend bandwidth sending mail to itself. :)

All I need is to be pointed in the right direction here, but if someone would give detailed explanations, that would be much appreciated as well.

Note: I have tried finding information on how to do this by google searching but to no avail. I have not experimented with postfix myself because I don't have any idea where to start.

2 Answers 2


If you are sending emails to your local domain then it will be delivered locally and not over internet. So, all you need to do is to configure Postfix accordingly. You will need to add your local domain to the mydestination in main.cf file in Postfix.

mydestination (default: $myhostname, localhost.$mydomain, localhost)

The list of domains that are delivered via the $local_transport mail delivery transport. By default this is the Postfix local(8) delivery agent which looks up all recipients in /etc/passwd and /etc/aliases. The SMTP server validates recipient addresses with $local_recipient_maps and rejects non-existent recipients.

See detail How-To's:


Setup a Local Only Email Server (Linux, Unix, Mac)

  • Thanks for the information! It's obviously much simpler than I'd imagined. :) How would I address the recipient in this case though? name@localhost? Also, will postfix accept mail locally from an external sender such as webuser@external.com? Jan 21, 2016 at 9:00
  • yes you can use @localhost by default or any other local domain name you can imagine. If you mean sender address, then yes. Here is the perfect guide that you need: gist.github.com/raelgc/6031274
    – Diamond
    Jan 21, 2016 at 9:12

You have at least 2 ways how to achieve this:

1) Don't use mail for this. You can just save contact form to database and not sending it away. Administrators will have section "Contact messages" in backend system when they can find messages from users.

2) Set mydestination atribute in postfix config. Postfix knows which domains manage by itself and when target domain is in this list, it will not send it out/in but just delivery to local mailbox. Don't worry, postfix is clever piece of software.

  • Thanks for the suggestion! I have also been thinking about making a backend system for support, but my colleagues feel like having to log in would be a hassle. :') Postfix sure is clever! I feel much more at ease now. :) Jan 21, 2016 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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