CSIE 1
Filtering mail
Speaker: Chung yu WuAdviser: Quincy WuDate: 2005/12/07
CSIE 2
Outilne
Mail protocol MUA 、 MTA 、 MDA Procmail Sendmail Predicament Regular Expression
CSIE 3
POP3
POP3(Post Office Protocol, version 3) • Is a client/server protocol in which e-mail
is received and held for you by your Internet server. Periodically, you check your mail-box on the server and download any mail .
• port: 110
CSIE 4
SMTP
SMTP (Simple Mail Transfer Protocol) • Is a protocol used in sending e-mail. • port:25
CSIE 5
IMAP
IMAP (Internet Message Access Protocol)• Is a standard protocol for accessing e-mail
from your local server. • Can view just the heading and the sender
of the letter and then decide whether to download the mail
CSIE 6
Send and received mail
Client AClient B
MTAMTA
MTA
relay mail
SMTP
send mail
relay mail
POP3
receive mail
IMAP read or manage mail
CSIE 7
MUA 、 MTA 、 MDA
MUA: Mail User AgentOutlook Express 、 Netscape Mail
MTA: Mail Transfer AgentSend mailReceived mail
MDA: Mail Delivery AgentMail filtering
CSIE 8
Send mail
CSIE 9
Received mail
CSIE 10
Relay
Mail server
sender
Spam Company
Open relay
CSIE 11
Procmail
MDA Filtering spam and virus Header: sender 、 receiver 、 address 、 title 。 Body: content Regular Expression
CSIE 12
Use Procmail
Forward
#vi $HOME/.forward
Insert “|exec /usr/local/bin/procmail” Procmailrc
#vi ~/.procmailrc
CSIE 13
.Procmailrc Rules
Notation Meaning
:0 Begin a recipe
: Use a lock file
* Begin a condition
^TO_ Look for a header that begins with To, Cc, Resent-To, or another destination specification
CSIE 14
.Procmailrc Rules(cont)
:0[flags] <one or more rules>
<which folder to store the matched mail> :0:
* ^Subject:*test/usr/mail/spam
:0:* ^Body:*test/usr/mail/spam
:0:* ^[email protected]
/usr/mail/s94321544
CSIE 15
Sendmail
MTA Relay-domains Access Aliases Local-host-names
CSIE 16
Relay-domains
Allow configure domains relay mail
#touch /etc/mail/relay-domains
#vi /etc/mail/relay-domains
163.22.16. / *allow 163.22.16.xxx */
www.john.ipv6.club.tw
CSIE 17
Access
Process configure source mail Rules:
Ok: Unconditional accept RELAY: Accept configure source mail REJECT: Refusal configure source mail
#vi /etc/mail/access163.22.16.40 OK163.22.16.33 RELAYJohn.ipv6.club.tw REJECT
CSIE 18
Aliases
Create a aliases to root
#vi /etc/mail/aliases
root: mutanwo
staff: Mary,Bill,Jordan
#newaliases
CSIE 19
Local-host-names
Received localhost send mail
#vi /etc/mail/local-host-names
ipv6.club.tw
john.ipv6.club.tw
ok
error
CSIE 20
Predicament
Freebsd 5.4
Perl5.8.6+sendmail+procmail+spamassassin
MTA: Sendmail
MDA: Procmail+Spamassassin
MUA: ELM
Q1:Procmail path:
ex:MAILDIR, PATH。
Q2: Procmail Log:
Q3:.forward file。 All mail send to /var/mail/mailnull not root
CSIE 21
Regular Expression
Search string
^ ^string ex: ’^test’ => testxxxx
$ string$ ex: ‘test&’ => xxxxtest
* string* ex: ‘b*’ => ,b,bb,bbb,bbbb…..△. any string ex: ‘a.c’ =>abc,acc,foc….
[ ] String set ex: ‘[br]ear’ =>bear,rear
CSIE 22
References
http://spamassassin.apache.org/ http://www.procmail.org/ http://www.sendmail.org/ http://www.regular-expressions.info/tutorial.html