{"id":714,"date":"2015-06-09T12:32:06","date_gmt":"2015-06-09T10:32:06","guid":{"rendered":"http:\/\/dety.net.ua\/?p=714"},"modified":"2015-06-09T17:10:20","modified_gmt":"2015-06-09T15:10:20","slug":"exchange-2010-smtp-telnet-auth-tls","status":"publish","type":"post","link":"https:\/\/dety.net.ua\/?p=714","title":{"rendered":"Exchange 2010 + SMTP + TELNET + AUTH + TLS"},"content":{"rendered":"<p>There are some interesting tricks:<\/p>\n<p>The commands to use in telnet with the &#8220;AUTH LOGIN&#8221; command:<\/p>\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"shell plain\">perl -MMIME::Base64 -e <\/code><code class=\"shell string\">'print encode_base64(\"username\");'<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"shell plain\">perl -MMIME::Base64 -e <\/code><code class=\"shell string\">'print encode_base64(\"password\");'<\/code><\/div>\n<\/div>\n<div class=\"line number2 index1 alt1\"><\/div>\n<div class=\"line number2 index1 alt1\">\n<div class=\"line number8 index7 alt1\"><strong><code class=\"plain plain\">EHLO mailserver.com<\/code><\/strong><\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"plain plain\">250-server1.mailserver.com Hello\u00a0 [1.1.1.2]<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"plain plain\">250-SIZE 52428800<\/code><\/div>\n<div class=\"line number11 index10 alt2\"><code class=\"plain plain\">250-PIPELINING<\/code><\/div>\n<div class=\"line number12 index11 alt1\"><code class=\"plain plain\">250-AUTH PLAIN LOGIN<\/code><\/div>\n<div class=\"line number13 index12 alt2\"><code class=\"plain plain\">250-STARTTLS<\/code><\/div>\n<div class=\"line number14 index13 alt1\"><code class=\"plain plain\">250 HELP<\/code><\/div>\n<div class=\"line number15 index14 alt2\"><strong><code class=\"plain plain\">AUTH LOGIN<\/code><\/strong><\/div>\n<div class=\"line number16 index15 alt1\"><code class=\"plain plain\">334 VXNlcm5hbWU6<\/code><\/div>\n<div class=\"line number17 index16 alt2\"><strong><code class=\"plain plain\">dXNlcm5hbWUuY29t<\/code><\/strong><\/div>\n<div class=\"line number18 index17 alt1\"><code class=\"plain plain\">334 UGFzc3dvcmQ6<\/code><\/div>\n<div class=\"line number19 index18 alt2\"><strong><code class=\"plain plain\">bXlwYXNzd29yZA==<\/code><\/strong><\/div>\n<\/div>\n<div class=\"line number2 index1 alt1\">BUT, Exchange has NTLM auth only: 250-AUTH NTLM<\/div>\n<div class=\"line number2 index1 alt1\">Some sites suggest:<\/div>\n<div class=\"line number2 index1 alt1\">\n<blockquote>\n<h6><\/h6>\n<h6>aspNetEmail had been running fine when they were emailing through Exchange 2007, however, when they upgraded, everything quit working, and started throwing 2 main errors.<\/h6>\n<h6>The 2 errors were:<\/h6>\n<h6>a) &#8220;504 5.7.4 Unrecognized authentication type&#8221;<br \/>\nAnd, once (a) was resolved, (b) happened:<br \/>\nb) &#8220;550 5.7.1 Client does not have permission to send as this sender&#8221;<\/h6>\n<h6>Lets talk about these 2 errors.<\/h6>\n<h6><strong>504 5.7.4 Unrecognized authentication type<br \/>\n<\/strong>In this particular instance, the customer was using the AuthLogin authentication scheme in aspNetEmail. However, starting in Exchange 2010, the only authentication mechanism enabled is NTLM. On their Exchange 2007 server, they had other authentication schemes enabled. So, as soon as they upgraded to Exchange 2010, aspNetEmail was throwing an exception, basically saying that AuthLogin was no longer supported.<\/h6>\n<h6>There are 2 ways to resolve this.<br \/>\na)\u00a0In the code, tell aspNetEmail to use the NTLM authentication scheme. In this instance, the customer didn&#8217;t want to touch the code base. So they decided for option (b), which was:<br \/>\nb)\u00a0Enable AuthLogin authenticaton on Exchange. To do this:<br \/>\nIn the Exchange console under server configuration:<br \/>\nSelect hub transport.<br \/>\nRight click\u00a0 the client server and select properties.<br \/>\nSelect the authentication tab.<br \/>\nCheck the Basic Authentication checkbox.<br \/>\nUncheck the Offer Basic only after TLS<\/h6>\n<h6>You may have to restart the Exchange services.<\/h6>\n<h6>Once this was resolved, the next error was thrown.<\/h6>\n<h6><strong>550 5.7.1 Client does not have permission to send as this sender<br \/>\n<\/strong>This error was being thrown because the FROM address the customer was using, was different than the Exchange mailbox they were relaying through. Like the error message implies, this is a permissions issue. To resolve this, the following steps were taken.<br \/>\na)From an Exchange Command prompt, run the following command:<br \/>\nAdd-AdPermission -Identity &#8220;Default Receive Connector&#8221; -User &#8220;NT AUTHORITY\\Authenticated Users&#8221; -ExtendedRights ms-Exch-SMTP-Accept-Any-Sender<\/h6>\n<h6>c)\u00a0On the user account, in Active Directory, under Security, under the SELF account, select the Manage Send As Permission option.<\/h6>\n<\/blockquote>\n<p>I&#8217;re better off using the first way &#8211; sending credentials in a plane mode is not a good way.<\/p>\n<p>If you have a ticked checkbox &#8220;Offer Basic authentication only after starting TLS&#8221; in your receive connector you won&#8217;t be able enter &#8220;AUTH LOGIN&#8221; command until you type: &#8220;STARTTLS&#8221;. But after that you won&#8217;t be able to type plain text commands &#8211; the must be encoded :).<\/p>\n<p>You can try this command &#8211; unsuccess for me\u00a0 now:<\/p>\n<pre><code>openssl s_client -debug -starttls smtp -crlf -connect localhost:25<\/code><\/pre>\n<p>OpenSSL will do the STARTTLS handshake for you and you will be able to pick up the conversation from there (decrypted automatically on the fly).<\/p>\n<p><span class=\"comment-copy\">You can specify a certificate with <code>-cert<\/code>. See the <a href=\"https:\/\/www.openssl.org\/docs\/apps\/s_client.html\" rel=\"nofollow\">man page<\/a> for the full list of options.<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>There are some interesting tricks: The commands to use in telnet with the &#8220;AUTH LOGIN&#8221; command: perl -MMIME::Base64 -e &#8216;print encode_base64(&#8220;username&#8221;);&#8217; perl -MMIME::Base64 -e &#8216;print encode_base64(&#8220;password&#8221;);&#8217; EHLO mailserver.com 250-server1.mailserver.com Hello\u00a0 [1.1.1.2] 250-SIZE 52428800 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP AUTH LOGIN 334 VXNlcm5hbWU6 dXNlcm5hbWUuY29t 334 UGFzc3dvcmQ6 bXlwYXNzd29yZA== BUT, Exchange has NTLM auth only: 250-AUTH [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,13],"tags":[],"class_list":["post-714","post","type-post","status-publish","format-standard","hentry","category-exchange","category-novosti"],"_links":{"self":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=714"}],"version-history":[{"count":5,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/714\/revisions"}],"predecessor-version":[{"id":719,"href":"https:\/\/dety.net.ua\/index.php?rest_route=\/wp\/v2\/posts\/714\/revisions\/719"}],"wp:attachment":[{"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dety.net.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}