This article outlines specifically how to use your server to send emails for server administration purposes only . Another term for this is setting up a null client.
For receiving emails and hosting it is recommend to use a dedicated mail server. Non-profits or small businesses should consider the using Google Apps which is free.
Install Postfix
Postfix is free and open-source mail transfer agent (MTA) that routes and delivers electronic mail. It is intended as a fast, easier-to-administer, and secure alternative to the widely-used Sendmail MTA.
Code Block | ||
---|---|---|
| ||
sudo apt-get install postfix |
Configuring Postfix
Basics of Postfix
Default installations of Postfix stores all messages in an mbox file. To see what directory it is using use the command,
Code Block | ||
---|---|---|
| ||
sudo postconf mail_spool_directory mail_spool_directory = /var/mail # This is the default directory. |
The newer maildir format is now recommened so follow the next section to change to maildir.
Setup Mail Delivery Account
The overall consensus is to use the maildir format with a mail directory being used for each user.
main.cf
Backup /etc/postfix/main.cf in case something goes wrong. All the subsequent commands modify main.cf,
Code Block |
---|
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.v0.0.bck |
The following command will do make the following changes,
- Set emails to the users home directory under a subfolder called Maildir.
- The trailing slash indicating a folder, will configure Postfix to use the maildir format. Note, if you forge the slash, a file called maildir will be generated in mbox format.
Code Block | ||
---|---|---|
| ||
sudo postconf -e 'home_mailbox = Maildir/' |
In most cases, your system is being used to send email outbound and not receive email or deliver the emails locally to the system.
Code Block | ||
---|---|---|
| ||
sudo postconf -e "inet_interfaces = loopback-only" # receive no mail from the network, and do not deliver any mail locally |
Reverse DNS
Warning |
---|
TBC - This should explain why we would want reverse dns. |
Reverse DNS unless delegated is managed by the ISP provider. Generally this means whoever manages the IP address of your server.
Setup spf Records
Warning |
---|
TBC - This section should be filled out with a general discussion of what spf is for and how to configure within Rackspace or your registrar. |
Test
Here is how to send a test email.
First install a simple mail program. In this example we will use mailx,
Code Block |
---|
sudo apt-get install bsd-mailx |
Next send the email,
Code Block | ||
---|---|---|
| ||
echo "test" | mail -s testsubject bhitch@imagecomics.com |
The log for a valid send will look something like this,
Code Block |
---|
tail /var/log/mail.log Jun 23 22:06:38 krypton postfix/pickup[15174]: AA67C2F824D: uid=2500 from=<tinpham> Jun 23 22:06:38 krypton postfix/cleanup[15988]: AA67C2F824D: message-id=<20110624020638.AA67C2F824D@myra> Jun 23 22:06:38 krypton postfix/qmgr[15175]: AA67C2F824D: from=<bhitch@krypton.com>, size=294, nrcpt=1 (queue active) Jun 23 22:06:39 krypton postfix/smtp[15990]: AA67C2F824D: to=<bhitch@rogers.com>, relay=mx1.rog.mail.yahoo.com[98.139.214.154]:25, delay=1, delays=0.02/0.01/0.25/0.74, dsn=2.0.0, status=sent (250 ok dirdel) Jun 23 22:06:39 krypton postfix/qmgr[15175]: AA67C2F824D: removed |
Tip |
---|
If you do not see your receive your test email, try looking in your spam folder. |
References
https://help.ubuntu.com/10.04/serverguide/C/postfix.html - How to setup postfix
http://www.linuxmail.info/mbox-maildir-mail-storage-formats/ - Deciding on Mbox vs Maildir
http://www.tummy.com/Products/vpostmaster/recipes/dovecotsasl.html - Syrus vs Dovecot
http://articles.slicehost.com/2010/3/1/barebones-postfix-install-for-ubuntu - Slicehost instructions on postfix, has notes here about reverse dns being needed
http://cloudservers.rackspacecloud.com/index.php/Postfix_-_Basic_Settings_in_main.cf - Rackspace instructions on postfix, the Slicehost actually seems better
http://www.postfix.org/STANDARD_CONFIGURATION_README.html - talks about null client