Configure postfix to send and receive to and from localhost

Does anyone know what needs to be configured for postfix so that emails can be sent to localhost and received from localhost?

e.g. send an email to [email protected] will:

  • result in user1 receiving an email in their mail client (configured to receive local emails)
  • user1 can then respond to [email protected]
  • Both user1 and user2 are configured on the same machine i.e. if there is no internet/network connection both these users can still send and receive to/from each other.

The reason I ask is because I want to set this up for a dev environment so that I can test an application I am developing.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can use a /etc/postfix/main.cf file like this one:

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

Short explanation of the parameters:

  • myorigin:
    this is the host name that the postfix program will use when
    sending email.
  • mydestination:
    this is the host name(s) that the postfix server
    considers itself able to receive mail for – you want localhost and
    any hostname on the machine (look into /etc/hosts) to be listed
    here.
  • mynetworks
    lists the “trusted” IP addresses from which postfix accepts any
    email
  • relayhost: if not empty, postfix will forward all emails to this
    server for delivery; you want this to be empty for local delivery to
    work.

You might want to have a look at
http://www.postfix.org/BASIC_CONFIGURATION_README.html
for a more authoritative explanation.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x