-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostfix.html
201 lines (164 loc) · 8.77 KB
/
postfix.html
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<link href="/images/favicon.png" rel="icon">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>trvrm.github.io</title>
<link rel="stylesheet" type="text/css" href="/theme/css/flatly.min.css" />
<link rel="stylesheet" type="text/css" href="/theme/css/style.css" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<link href="/theme/css/pygments/tango.css" rel="stylesheet">
<meta name="tags" content="postfix" />
<meta name="tags" content="email" />
</head>
<body>
<section class="hero is-primary">
<!-- Hero header: will stick at the top -->
<div class="hero-head">
<nav class="navbar ">
<div class="navbar-menu is-active">
<div class="navbar-end">
<a class="navbar-item" href="https://twitter.com/trvrm">
<span class="icon"> <i class="fa fa-twitter"></i> </span>
twitter
</a>
<a class="navbar-item" href="https://github.com/trvrm">
<span class="icon"> <i class="fa fa-github"></i> </span>
github
</a>
</div>
</div>
</div>
</div>
<!-- Hero content: will be in the middle -->
<div class="hero-body">
<div class="container has-text-centered">
<p class="title is-1">trvrm.github.io</p>
</div>
</div>
<div class="hero-foot">
<nav class="navbar ">
<div class="navbar-brand is-active">
<a href="/" class="navbar-item" >
trvrm.github.io
</a>
</div>
<div class="navbar-menu is-active">
<div class="navbar-start">
<a class="navbar-item " href="/category/database.html">Database</a>
<a class="navbar-item " href="/category/software.html">Software</a>
<a class="navbar-item is-active " href="/category/systems.html">Systems</a>
</div>
</div>
</nav>
</div>
</section>
<section class="section">
<div class="container has-text-centered">
<p class="title is-3">
<a href="/postfix.html" rel="bookmark" title="Permalink to Postfix">
Postfix
</a>
</p>
<p class="subtitle is-5">
Thu 01 January 2015
</p>
</div>
<hr>
<div class="content ">
<p>Postfix is a ghastly horror that really should be quietly eliminated. But that truism hides a deeper issue - email itself is a ghastly horror, the result of 30 years of hacks, edge-cases, non-conformant implementations and competing design constraints, that only persists because we still haven't come up with anything better.</p>
<p>Take the simple question 'what is a valid email address'.</p>
<p>I have a couple of standard regexes I use to validate email addresses,
such as <code class="code">
^[A-Z0-9._%+-]+@[A-Z0-9.-]+ .[A-Z]{2,4}$</code>
,
but having spent years building mailing systems,
the best answer I can come up with is
<em>a valid email address is one that gets delivered to its destination</em>.</p>
<p>So, Postfix. If you ever need a taste of purgatory, take some time to browse through
the source code, a terrifying mix of old-school C and Perl. I once needed to create
a utility to monitor the state of a Postfix DEFERRED queue, and found it was vastly
easier to write my own queue parser in Python than understand the source to the existing
<code class="code">
qshape</code>
utility. Whoever wrote that clearly has an aversion to variable names
that are more than one character long.</p>
<p>Actually configuring a functional Postfix system requires commiting yourself to a long
pilgrimage across the net, picking up scattered bits of wisdom from the hardy travellers
who have passed this way before, and recorded their insights in ancient forgotten blog
posts and wiki pages.</p>
<p>Documents such as <a class="reference external" href="http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu-10.04">http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu-10.04</a>
include gems like <em>'this howto is meant as a practical guide; it does not cover the
theoretical backgrounds'</em>.</p>
<p>You have been warned, it seems to be saying. Configuring this system really requires at
the very least a Masters degree in Advanced Email Hackery.</p>
<a class="reference external image-reference" href="http://www.linuxjournal.com/article/9454"><img alt="postfix flowchart" src="images/postfix_flowchart.jpg" /></a>
<p>That image is from this <a class="reference external" href="http://www.linuxjournal.com/article/9454">article</a> at Linux Journal, which is actually
a pretty good and comprehensive introduction to the architecture of Postfix</p>
<p>The <em>key</em> insight that everything else hangs on is that Postfix is <em>not</em> a program. Postfix is a large
<em>collection</em> of programs: some of which interact with the user, and a large number which run in the
background and perform all the various tasks of gathering, processing and delivering email.</p>
<p>These programs, together with a rather complex set of folders under <code class="code">
/var/spool/postfix</code>
that store messages as they work their way through
the system, and another set of rather complex configuration files under <code class="code">
/etc/postfix</code>
, are what comprises the
complete mail delivery system.</p>
<p>To add to the fun, many postfix configuration settings can be stored in MySQL, and it's possible to run multiple postfix instances in
parallel with each other.</p>
<div class="highlight"><pre><span></span>$ pstree -a
├─master
│ ├─anvil -l -t unix -u -c
│ ├─pickup -l -t unix -u -c
│ ├─qmgr -l -t unix -u
│ ├─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span> -s <span class="m">2</span>
│ ├─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span> -s <span class="m">2</span>
│ └─tlsmgr -l -t unix -u -c
├─master
│ ├─anvil -l -t unix -u -c
│ ├─pickup -l -t unix -u -c
│ ├─qmgr -l -t unix -u
│ ├─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
│ └─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
├─master
│ ├─anvil -l -t unix -u -c
│ ├─pickup -l -t unix -u -c
│ ├─qmgr -l -t unix -u
│ ├─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
│ └─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
├─master
│ ├─anvil -l -t unix -u -c
│ ├─pickup -l -t unix -u -c
│ ├─qmgr -l -t unix -u
│ ├─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
│ └─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
├─master
│ ├─anvil -l -t unix -u -c
│ ├─pickup -l -t unix -u -c
│ ├─qmgr -l -t unix -u
│ ├─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
│ └─smtpd -n smtp -t inet -u -c -o <span class="nv">stress</span><span class="o">=</span>
</pre></div>
<p>That's a lot of processes....</p>
<p>And yet, despite this, Postfix seems to be about the best there is. Over the last
few years I've built and maintained a massively parallel mail delivery, management
and monitoring system on top of Postfix that, at the last count, had successfully
delivered almost 10 million messages for clients of <a class="reference external" href="http://nooro.com">Nooro Online Research</a>.</p>
</div>
</section>
<footer class="footer">
<div class="container">
<div class="content has-text-centered">
<p>
Powered by <a href="http://getpelican.com/">Pelican</a>, <a href="http://python.org">Python</a>,
and <a href="http://bulma.io/">Bulma</a>
</p>
<p class="subtitle is-6">Ubi Caritas et Amor, Deus Ibi Est</p>
</div>
</div>
</footer>
</body>
</html>