"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."
You'll still need to deliver it. You just need to override "where" it's delivered.
"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."
This can actually be done using only the default postfix installation package (no need for postfix-pcre).
1.) Following a tutorial here, edit 2 lines in the /etc/postfix/master.cf
file to prevent any mail from being delivered externally (it gets stuck in the local mail queue):
smtp unix - - - - - local
relay unix - - - - - local
2.) Create a file in /etc/postfix
called virtual
. Place the following line within that file, replacing <USERNAME>
with the local user account name you want all mail to be delivered to:
/.*/ <USERNAME>
3.) Run the following command to create the correct database file for postfix to look-up this new "virtual alias map". The new, autogenerated database file will be called "virtual.db"
sudo postmap /etc/postfix/virtual
4.) Add the following line to /etc/postfix/main.cf
virtual_alias_maps = regexp:/etc/postfix/virtual
5.) Restart postfix:
sudo service postfix restart
Now all mail, regardless of the sender, recipient or program that points to this SMTP server, will be delivered locally to the specified user. There are numerous options to read / retrieve these messages now. If you install an IMAP or POP3 courrier (such as dovecot), you can use a Mail User Agent (Thunderbird, Outlook, etc.) to connect to your local mailbox and read the messages.