-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path108-3-Mail-Transfer-Agent-(MTA)-basics
152 lines (124 loc) · 6.47 KB
/
108-3-Mail-Transfer-Agent-(MTA)-basics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
####################################################################
108.3 Mail Transfer Agent (MTA) basics
####################################################################
Candidates should be aware of the commonly available MTA programs and be able to perform basic forward and alias configuration on a client host. Other configuration files are not covered.
Key Knowledge Areas
& Create e-mail aliases.
& Configure e-mail forwarding.
& Knowledge of commonly available MTA programs (postfix, sendmail, qmail, exim) (no configuration)
################################
Terms and Utilities
################################
& ~/.forward
& sendmail emulation layer commands
& newaliases
& mail
& mailq
& postfix
& sendmail
& exim
& qmail
################################
MTAs
################################
Mai Transfer Agents or MTAs are programs which handle emails in your operating system. There are lot of MTAs available and each distro or sysadmin uses the one she likes more.
################################
sendmail
################################
Is one of the oldest options available. It is big and difficult to configure and keep safe and secure so very few systems use it as default MTA.
################################
qmail
################################
qmail is an attempt to provide an ultra secure MTA while keeping the MTA compatible with sendmail ideas. It is modular and claims to be free of any security bug. It also claim to be the 2nd popular mail agent on the Internet.
qmail is not a GPL software. It is Public Domain.
################################
exim
################################
It aims to be a general and flexible mailer with extensive facilities for checking incoming e-mail. It is feature rich with ACLs, authentication, ...
################################
postfix
################################
This is a new alternative to sendmail and uses easy to understand configuration files. It supports multiple domains, encryption, etc. Postfix is what you may find on most distros as default.
################################
sendmail emulation layer
################################
As I already said, sendmail is the oldest MTA which is still active. Other MTAs respect his age and provide a sendmail emulation layer to keep themselves backward compatible with it. In other words you can type sendmail or mailq on your command line regardless of what MTA you've installed.
################################
aliases
################################
There are some mail aliases on the system. Defined in /etc/aliases.
$ cat /etc/aliases
# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root # <--- I'm using this sample
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: mojtaba
This tells the system if there is a message for 'usenet' it will sent to the root user. Note that in the last line, mojtaba is reading the root emails. This line lets me read emails sent to root without needing to login with root.
when this file is update, the newaliases should be run!
root@funlife:~# newaliases
root@funlife:~#
################################
sending mail
################################
It is possible to send an email from the command line using the mail command:
[mojtaba@funlife ~]$ mail news
Subject: Email to news user
hahah.. we know where this will go.
this will go to root and then to mojtaba!
Hi mojtaba!
Cc:
[mojtaba@funlife ~]$ mail
Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/mojtaba": 12 messages 12 new
>N 1 root@funlife Sat Jan 02 08:50 39/1373 apt-listchanges: news for f
N 2 root@funlife Sat Jan 02 09:01 165/7438 apt-listchanges: news for f
N 3 mojtaba@funlife Sat Jan 02 19:58 18/640 *** SECURITY information fo
N 4 mojtaba@funlife Sat Jan 02 20:04 18/631 *** SECURITY information fo
N 5 mojtaba@funlife Sun Jan 03 10:15 18/664 *** SECURITY information fo
N 6 root@funlife Mon Jan 04 12:42 27/941 Cron <mojtaba@funlife> /home/j
N 7 root@funlife Mon Jan 04 17:11 26/845 apt-listchanges: news for f
N 8 root@funlife Tue Jan 05 18:42 27/945 Cron <mojtaba@funlife> /home/j
N 9 root@funlife Wed Jan 06 09:17 46/1788 apt-listchanges: news for f
N 10 root@funlife Thu Jan 07 12:42 27/945 Cron <mojtaba@funlife> /home/j
N 11 root@funlife Thu Jan 07 18:42 27/943 Cron <mojtaba@funlife> /home/j
N 12 mojtaba@funlife Thu Jan 7 19:53 17/478 Email to news user
& 12
Message 12:
From mojtaba@funlife Thu Jan 7 19:53:08 2016
X-Original-To: news
To: news@funlife
Subject: Email to news user
Date: Thu, 7 Jan 2016 19:53:08 +0330 (IRST)
From: mojtaba@funlife (mojtaba)
hahah.. we know where this will go.
this will go to root and then to mojtaba!
Hi mojtaba!
& d
& q
Held 11 messages in /var/mail/mojtaba
################################
local forwards
################################
We saw that it is possible to forward emails using the /etc/aliases. That file is not writable by normal users so what a normal user like mojtaba should do?
Each user can create a .forward file in her own directory and all mail targeted to that user will be forwarded to that address.
You can even put a complete email address like [email protected] in your .forward file.
mail command is not part of LPIC102 but it is good if you play and learn it to some extent. It also can send email from within the scripts like 'echo -e "email content" | mail -s "email subject" "[email protected]"'
################################
mailq
################################
This command lists the mail queue. Each entry shows the queue file ID, message size, arrival time, sender, and the recipients that still need to be delivered. If mail could not be delivered upon the last attempt, the reason for failure is shown. The sysadmin can use this command to check the status of emails still in the queues.
$ mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
AA52C228E6B 468 Thu Jan 7 19:59:41 mojtaba@funlife
(connect to alt2.gmail-smtp-in.l.google.com[2404:6800:4003:c01::1a]:25: Network is unreachable)
-- 0 Kbytes in 1 Request.