mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / SMTP.mdwn
1 Verizon blocks outgoing connections on port 25 ([SMTP][]) unless you
2 are connecting to their `outgoing.verizon.net` message exchange
3 server.  This server requires authentication with your Verzon
4 username/password before it will accept your mail.  For the purpose of
5 this example, our Verizon username is `jdoe`, our Verizon password is
6 `YOURPASS`, and were sending email from `me@example.com` to
7 `you@target.edu`.
8
9     $ nc outgoing.verizon.net 25
10     220 vms173003pub.verizon.net -- Server ESMTP (...)
11     mail from: <jdoe@example.com>  
12     550 5.7.1 Authentication Required
13     quit
14     221 2.3.0 Bye received. Goodbye.
15
16 Because authenticating over an unencrypted connection is a Bad Idea™,
17 I was looking for an encrypted way to send my outgoing email.
18 Unfortunately, Verizon's exchange server does not support [STARTTLS][]
19 for encrypting connections to `outgoing.verizon.net:25`:
20
21     $ nc outgoing.verizon.net 25
22     220 vms173003pub.verizon.net -- Server ESMTP (...)
23     ehlo example.com
24     250-vms173003pub.verizon.net
25     250-8BITMIME
26     250-PIPELINING
27     250-CHUNKING
28     250-DSN
29     250-ENHANCEDSTATUSCODES
30     250-HELP
31     250-XLOOP E9B7EB199A9B52CF7D936A4DD3199D6F
32     250-AUTH DIGEST-MD5 PLAIN LOGIN CRAM-MD5
33     250-AUTH=LOGIN PLAIN
34     250-ETRN
35     250-NO-SOLICITING
36     250 SIZE 20971520
37     starttls
38     533 5.7.1 STARTTLS command is not enabled.
39     quit
40     221 2.3.0 Bye received. Goodbye.
41
42 Verizon [recommends][verizon] pre-STARTTLS approach of wrapping the
43 whole SMTP connection in TLS ([SMTPS][]), which it provides via
44 `outgoing.verizon.net:465`:
45
46     $ python -c 'from base64 import *; print b64encode("\0jdoe@verizon.net\0YOURPASS")'
47     AGpkb2VAdmVyaXpvbi5uZXQAWU9VUlBBU1M=
48     $ openssl s_client -connect outgoing.verizon.net:465
49     ...
50     220 vms173013pub.verizon.net -- Server ESMTP (...)
51     ehlo example.com
52     250-vms173013pub.verizon.net
53     250-8BITMIME
54     250-PIPELINING
55     250-CHUNKING
56     250-DSN
57     250-ENHANCEDSTATUSCODES
58     250-HELP
59     250-XLOOP 9380A5843FE933CF9BD037667F4C950D
60     250-AUTH DIGEST-MD5 PLAIN LOGIN CRAM-MD5
61     250-AUTH=LOGIN PLAIN
62     250-ETRN
63     250-NO-SOLICITING
64     250 SIZE 20971520
65     auth plain AGpkb2VAdmVyaXpvbi5uZXQAWU9VUlBBU1M
66     235 2.7.0 plain authentication successful.
67     mail from: <me@example.com>
68     250 2.5.0 Address Ok.
69     rcpt to: <you@target.edu>
70     250 2.1.5 you@target.edu OK.
71     data
72     354 Enter mail, end with a single ".".
73     From: Me <me@example.com>
74     To: You <you@target.edu>
75     Subject: testing
76
77     hello world 
78     .
79     250 2.5.0 Ok, envelope id 4BHMFEZ7PHSETMT6@vms173013.mailsrvcs.net
80     quit
81     221 2.3.0 Bye received. Goodbye.
82     closed
83
84 This works, but with the rise of STARTTLS, getting your local
85 [[Postfix]] mail server to support SMTPS requires a bit of
86 [fancyness][] with [[stunnel]].  The stunnel workaround is not too
87 complicated, but I also wanted to look into the [submission][]
88 protocol (port 587), which adapts SMTP (designed for message transfer)
89 into a similar protocol for message submission.  Unfortunately,
90 Verizon does not support STARTTLS here either.
91
92     $ nc outgoing.verizon.net 587
93     220 vms173005.mailsrvcs.net -- Server ESMTP (...)
94     ehlo example.com
95     250-vms173005.mailsrvcs.net
96     250-8BITMIME
97     250-PIPELINING
98     250-CHUNKING
99     250-DSN
100     250-ENHANCEDSTATUSCODES
101     250-EXPN
102     250-HELP
103     250-XADR
104     250-XSTA
105     250-XCIR
106     250-XGEN
107     250-XLOOP DA941C5B31BE4B102BB69B809BC66C4A
108     250-AUTH DIGEST-MD5 PLAIN LOGIN CRAM-MD5
109     250-AUTH=LOGIN PLAIN
110     250-NO-SOLICITING
111     250 SIZE 20971520
112     starttls
113     533 5.7.1 STARTTLS command is not enabled.
114     quit
115     221 2.3.0 Bye received. Goodbye.
116
117 In conclusion, Verizon supports a number of email submission
118 standards, but the only secure approach is to use the outdated SMTPS.
119 See my [[Postfix]] post for details on configuring Postfix to use
120 Verizon's server for outgoing mail.
121
122 There are a number of good SMTP authentication tutorials out there.  I
123 used [John Simpson][JS] and [Erwin Hoffmann's][EH] tutorials.  For
124 cleaner examples of my testing tools (`nc` and `openssl s_client`),
125 see my [[simple_servers]] post.
126
127 [SMTP]: http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
128 [STARTTLS]: http://en.wikipedia.org/wiki/STARTTLS
129 [verizon]: http://www22.verizon.com/residentialhelp/fiosinternet/email/setup+and+use/questionsone/86782.htm
130 [SMTPS]: http://en.wikipedia.org/wiki/SMTPS
131 [fancyness]: http://www.postfix.org/TLS_README.html#client_smtps
132 [submission]: http://tools.ietf.org/html/rfc4409
133 [JS]: http://qmail.jms1.net/test-auth.shtml
134 [EH]: http://www.fehcom.de/qmail/smtpauth.html
135
136 [[!tag tags/linux]]
137 [[!tag tags/tools]]
138 [[!tag tags/web]]