Difference between revisions of "Mail Server"
| Line 1: | Line 1: | ||
== General == | == General == | ||
See https://help.ubuntu.com/community/MailServer for an introduction to MTA/Spamassassin | See https://help.ubuntu.com/community/MailServer for an introduction to MTA/Spamassassin | ||
| + | |||
| + | ; MTA : Mail Transport Agent (generally SMTP) | ||
| + | ; MDA : Mail Delivery Agent | ||
| + | ; MUA : Mail User Agent (generally POP3 or IMAP) | ||
Briefly, the workflow for mail delivery is: | Briefly, the workflow for mail delivery is: | ||
| − | '''[Internet] -> postfix (MTA) -> procmail (MDA) | + | '''[Internet] -> postfix (MTA) -> SpamAssassin -> postfix (MTA) -> procmail (MDA) -> $HOME/Maildir''' |
and for mail viewing: | and for mail viewing: | ||
| Line 15: | Line 19: | ||
== Postfix == | == Postfix == | ||
| + | === Configuring SpamAssassin as a content filter === | ||
| + | Add to /etc/postfix/master.cf: | ||
| + | <pre> | ||
| + | spamassassin unix - n n - - pipe | ||
| + | user=spamd argv=/usr/bin/spamc -f -e | ||
| + | /usr/sbin/sendmail -oi -f ${sender} ${recipient} | ||
| + | </pre> | ||
| + | Again in /etc/postfix/master.cf, change the smtp content filters to: | ||
| + | <pre> | ||
| + | smtp inet n - - - - smtpd | ||
| + | -o content_filter=spamassassin | ||
| + | </pre> | ||
| + | |||
| + | === Configuring postfix delivery method === | ||
| + | The following config should be placed within /etc/postfix/main.cf | ||
| + | ==== To use postfix's builtin MDA with mbox format (/var/spool/mail/$USER) ==== | ||
| + | <pre> | ||
| + | # Use mbox mailboxes (the default) | ||
| + | home_mailbox = mbox | ||
| + | </pre> | ||
| + | Ensure no '''mailbox_command''' is specified | ||
| + | |||
| + | ==== To use postfix's builtin MDA with Maildir formar ($HOME/Maildir/*) ==== | ||
| + | <pre> | ||
| + | # Use Maildir style mailboxes | ||
| + | home_mailbox = Maildir/ | ||
| + | </pre> | ||
| + | Ensure no '''mailbox_command''' is specified | ||
| + | |||
| + | ==== To use procmail as external MDA ==== | ||
| + | <pre> | ||
| + | # Use procmail | ||
| + | mailbox_command = /usr/bin/procmail | ||
| + | </pre> | ||
| + | Ensure no '''home_mailbox''' is specified | ||
| + | |||
| + | === Configuring mail for an unknown destination to route to a specific user: | ||
| + | <pre> | ||
| + | # Redirect unknown users to andrew | ||
| + | luser_relay = andrew | ||
| + | local_recipient_maps = | ||
| + | </pre> | ||
| + | |||
| + | === Hardening postfix === | ||
| + | Add the following to /etc/postfix/main.cf: | ||
| + | <pre> | ||
| + | ## Restrictions | ||
| + | # Require a valid handshake, with the sender announcing its name | ||
| + | smtpd_helo_required = yes | ||
| + | # Require the sending server to have an A or MX record in DNS | ||
| + | #smtpd_sender_restrictions = hash:/etc/postfix/sender_access,reject_unknown_sender_domain | ||
| + | smtpd_sender_restrictions = reject_unknown_sender_domain | ||
| + | # Require the recipient to be a configured destination, unless from mynetworks (NB. This is default, anyway) | ||
| + | smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination | ||
| + | </pre> | ||
| + | |||
=== Emptying deferred queue === | === Emptying deferred queue === | ||
To attempt redelivery: | To attempt redelivery: | ||
Revision as of 14:30, 4 November 2007
Contents
General
See https://help.ubuntu.com/community/MailServer for an introduction to MTA/Spamassassin
- MTA
- Mail Transport Agent (generally SMTP)
- MDA
- Mail Delivery Agent
- MUA
- Mail User Agent (generally POP3 or IMAP)
Briefly, the workflow for mail delivery is:
[Internet] -> postfix (MTA) -> SpamAssassin -> postfix (MTA) -> procmail (MDA) -> $HOME/Maildir
and for mail viewing:
$HOME/Maildir -> Courier (IMAP MUA) -> Thunderbird/Outlook
or
$HOME/Maildir -> Mutt/Pine
Postfix
Configuring SpamAssassin as a content filter
Add to /etc/postfix/master.cf:
spamassassin unix - n n - - pipe
user=spamd argv=/usr/bin/spamc -f -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}
Again in /etc/postfix/master.cf, change the smtp content filters to:
smtp inet n - - - - smtpd
-o content_filter=spamassassin
Configuring postfix delivery method
The following config should be placed within /etc/postfix/main.cf
To use postfix's builtin MDA with mbox format (/var/spool/mail/$USER)
# Use mbox mailboxes (the default) home_mailbox = mbox
Ensure no mailbox_command is specified
To use postfix's builtin MDA with Maildir formar ($HOME/Maildir/*)
# Use Maildir style mailboxes home_mailbox = Maildir/
Ensure no mailbox_command is specified
To use procmail as external MDA
# Use procmail mailbox_command = /usr/bin/procmail
Ensure no home_mailbox is specified
=== Configuring mail for an unknown destination to route to a specific user:
# Redirect unknown users to andrew luser_relay = andrew local_recipient_maps =
Hardening postfix
Add the following to /etc/postfix/main.cf:
## Restrictions # Require a valid handshake, with the sender announcing its name smtpd_helo_required = yes # Require the sending server to have an A or MX record in DNS #smtpd_sender_restrictions = hash:/etc/postfix/sender_access,reject_unknown_sender_domain smtpd_sender_restrictions = reject_unknown_sender_domain # Require the recipient to be a configured destination, unless from mynetworks (NB. This is default, anyway) smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
Emptying deferred queue
To attempt redelivery:
sudo postfix flush
To simply delete all deferred mails:
sudo postsuper -d ALL
SpamAssassin
Pyzor
Meaning of output like:
82.94.255.100:24441 (200, 'OK') 1206 0
- 82.94.255.100
- 24441
- Pyzor server
- (200, 'OK')
- HTTP response from server
- 1206
- Number of spam matches for tested message
- 0
- Number of whitelist (definite non-spam) matches for tested message
Pyzor will return 0 (identifying the message as spam) only if number of spam matches > 0 and number of whitelist matches = 0.