SENDMAIL
Giới thiệu
MUAs, MTAs, and MDAs
Cấu trúc của 1 Email Message
SMTP và the Message Envelope
Lịch sử sendmail
The Mail Queue
Aliases
Biên dịch sendmail và cài đặt
Tại sao dùng Berkeley sendmail?
Tải Source Code
Cấu hình Build-Time
Database Map Support
Ví dụ site.config.m4
Biên dịch sendmail
Cấu hình sendmail
File cấu hình có thể làm gì ?
So sánh .cf files với .mc files
Cấu trúc của .mc File
Biến cấu hình
FEATURE() Macros
Masquerading
Relaying
Database Maps
Sinh ra .cf file từ .mc file
Anti-Spam
Định nghĩa "spam"
No Default Relaying
Access Control Database
Better Checking on Sender Information
Chạy sendmail:
Các tham số dòng lệnh
Khởi động
MUAs, MTAs, and MDAs
Part
What It Does
Examples
Mail User
Agent
(MUA)
Mail
Transfer
Agent
(MTA)
MUA là chương trình dùng để
đọc và gửi mail. Có thể gọi là
mail client.
MTA làm nhiệm vụ như là "mail
router". Nó nhận mail từ MUA lẫn
MTA, căn cứ vào header của
mail mà nó quyết định chuyển đi
bằng cách nào
MDA chấp nhận các mail từ MTA
và chuyển đi cụ thể đến user
elm, pine,
Outlook,
Eudora
sendmail,
qmail,
exchange
server
Mail
Delivery
Agent
(MDA)
mail.local
procmail
Ví dụ
MTA: phần quan trọng nhất. Nó chịu
trách nhiệm làm các công việc chuyển
mail “thông minh".
Quá trình gửi nhận mail
1.
2.
3.
4.
5.
6.
jsmith's MUA (pine, outlook, … ) trên host1.uiuc.edu chuyển
message đến MTA (sendmail) trên local host.
MTA (sendmail) chú ý message được đánh địa chỉ đến 1 user
tại host2.uiuc.edu. Khi đó nó được cấu hình để biết rằng nó
có thể đến host2.uiuc.edu thông qua SMTP, nó chuyển
message sang SMTP MDA (thường SMTP MDA được build sẵn
trong sendmail, nhưng các MDA khác có thể là 1 chương
trình ngoài).
SMTP MDA kết nối vào MTA trên host2.uiuc.edu (sendmail)
và gửi nó 1 message.
MTA trên host2.uiuc.edu (sendmail) thông báo rằng message
được đánh địa chỉ đến 1 user trên localhost, do đó nó
chuyển message vào local MDA.
Local MDA lưu message trong mailbox của johndoe .
Kế tiếp johndoe kết nối vào host2.uiuc.edu và chạy MUA,
message sẽ ở đó để anh ta đọc.
Structure of an Email Message
Email messages có 2 phần :
Headers: dòng có dạng "field: value" chứa
thông tin về message, như là "To:", "From:",
"Date:", and "Message-ID:"
Body: nội dung của message
From [email protected] Tue Nov 30 09:54:29 2010
Return-Path:
Received: from alibaba.citd.edu.vn (alibaba [127.0.0.1])
by alibaba.citd.edu.vn (8.12.8/8.12.8) with ESMTP id
oAU2sNOR003125
for ; Tue, 30 Nov 2010 09:54:28
+0700
Received: (from root@localhost)
by alibaba.citd.edu.vn (8.12.8/8.12.8/Submit) id oAU2sNKh003123
for natuan; Tue, 30 Nov 2010 09:54:23 +0700
Date: Tue, 30 Nov 2010 09:54:23 +0700
From: root
Message-Id: <[email protected]>
To: [email protected]
Subject: Test sendmail program
This is the message body.
SMTP and the Message Envelope
[root@alibaba mail]# telnet 172.16.10.1 25
Trying 172.16.10.1...
Connected to 172.16.10.1.
Escape character is '^]'.
220 pascal.citd.edu.vn ESMTP Sendmail
8.12.8/8.12.5; Sun, 30 Nov 2003 09:14:37 0500
helo pascal
250 pascal.citd.edu.vn Hello [192.168.1.13],
pleased to meet you
mail from: [email protected]
250 2.1.0 [email protected]... Sender ok
Quá trình gửi mail
rcpt to:[email protected]
250 2.1.5 [email protected] ok
data
354 Enter mail, end with "." on a line by itself
subject: Test mail from alibaba CITD
This is the message body
.
250 2.0.0 hAUEEb7S003989 Message accepted
for delivery
quit
221 2.0.0 pascal.citd.edu.vn closing connection
Connection closed by foreign host.
Lịch sử sendmail
The Past:
sendmail là một trong những MTA cổ nhất và dùng
nhiều nhất trên Internet
Bản gốc được viết trước khi Internet được chuẩn
hoá
Được thiết kế đủ linh hoạt để chuyển mail cho các
mail systems khác nhau bất kể tính chất của nó
Today:
Internet được chuẩn hoá nhiều hơn
Dùng SMTP (Simple Mail Transfer Protocol)
Nhiều tính năng cũ của sendmail được bỏ qua
Mặc dù dùng SMTP, MTA vẫn còn được dùng cho
việc dẫn đường mail!
The Mail Queue
sendmail chạy background đợi new
messages. Khi có 1 kết nối đến, một child
process được sinh ra để xử lý kết nối, trong
khi parent process quay trở lại tiếp tục đợi
new connections.
Khi một message được nhận, sendmail
child process đặt chúng vào mail queue
(/var/spool/mqueue) và theo định kỳ nó sẽ
được chuyển đi. Sau khi mail được chuyển
đi, nó sẽ bị xoá khỏi mqueue
Messages nằm trong mqueue sẽ ở đó cho
đến khi queue được xử lý. parent sendmail
sẽ thường xuyên fork một child process để
chuyển bất cứ mail nào còn nằm trong
queue theo những quãng thời gian nhất
định
Xử lý mqueue
Tập tin /etc/mail/aliases
Một alias cho phép sendmail chuyển hướng
(redirect) mail gửi đến một address. mail này
có thể được redirected đến một email address
khác
sendmail's alias database thường được lưu
dạng flat-text trong file /etc/mail/aliases.
Ví dụ:
# Basic system aliases -- these MUST be present.
MAILER-DAEMON: postmaster
postmaster: tuanna
root: tuanna
tuan: [email protected], [email protected]
Tập tin /etc/mail/aliases
Mailling list
k11: [email protected],
[email protected] , [email protected] ,
[email protected] , [email protected],
[email protected],
[email protected], [email protected] ,
[email protected] ,
[email protected] , [email protected],
[email protected], [email protected],
[email protected], [email protected]
, [email protected] , [email protected],
[email protected] ,
[email protected], [email protected],
[email protected],
[email protected], [email protected]
Tập tin /etc/mail/aliases
Sau khi đã hiệu chỉnh lập tin aliase ta
phải compile thành binary để
sendmail hiểu.
Sử dụng lệnh newaliases. Tập tin
aliases.db sẽ được sinh ra
Tại sao dùng Berkeley sendmail?
Security fixes: Các lỗi về security
được cập nhật và sửa thường xuyên
Features: Các tính năng của
sendmail hỗ trợ rất nhiều
Standards: Sendmail là một mail
server hỗ trợ chuẩn SMTP và được
chuẩn hoá trên Internet
Support: Sendmail được hỗ trợ
http://www.sendmail.org
Sendmail source code
Có thể tải sendmail source code từ :
ftp://ftp.sendmail.org/pub/sendmail
(home site)
ftp://uiarchive.uiuc.edu/pub/packag
es/mail/sendmail (local mirror)