{"id":163,"date":"2018-04-05T17:17:28","date_gmt":"2018-04-05T15:17:28","guid":{"rendered":"http:\/\/zupertails.be\/wur\/?p=163"},"modified":"2018-04-05T17:33:32","modified_gmt":"2018-04-05T15:33:32","slug":"smtp-relay-on-your-windows-server-for-use-with-office-365","status":"publish","type":"post","link":"https:\/\/zupertails.be\/wur\/?p=163","title":{"rendered":"SMTP relay on your Windows server for use with Office 365"},"content":{"rendered":"<h2>Antique software ? No TLS\/SSL support for outgoing mail ?<\/h2>\n<h3>No problem !<\/h3>\n<p>If you stumble upon this article through a Google search (who uses Bing, anyway&#8230;), you&#8217;re probably wondering how to solve the following issue (or something similar) :<\/p>\n<figure id=\"attachment_166\" aria-describedby=\"caption-attachment-166\" style=\"width: 300px\" class=\"wp-caption alignright\"><img loading=\"lazy\" class=\"wp-image-166 size-medium\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/Antique-Mall-Software-Main-Menu-300x206.gif\" alt=\"\" width=\"300\" height=\"206\" \/><figcaption id=\"caption-attachment-166\" class=\"wp-caption-text\">It&#8217;s all about the Pentiums, baby !<\/figcaption><\/figure>\n<p>You have this old invoicing software that doesn&#8217;t get updates anymore ever since 2008 and relies on port 25 &#8211; unauthenticated &#8211; to send mails through your ISP&#8217;s outgoing mail server.<\/p>\n<p>You happen to have this beautiful product called &#8216;Office 365&#8217; and use its mail functionality for your own domain name. This domain name is used as outgoing mail domain in your software.<\/p>\n<p>Luckily, you still have a Windows Server randomly lying about (hopefully 2008 R2 or higher, but this trick works with older stuff as well &#8211; also : this works on a Windows 7\/8\/10 , even though the <a href=\"https:\/\/www.howtogeek.com\/112455\/how-to-install-iis-8-on-windows-8\/\">IIS install method will be different<\/a>)<\/p>\n<h2>Installing SMTP in IIS<\/h2>\n<ol>\n<li>2012 R2 Server<br \/>\n<b class=\"ocpLegacyBold\"><img loading=\"lazy\" class=\"size-full wp-image-167 alignright\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/2012r2.png\" alt=\"\" width=\"150\" height=\"150\" \/>Install Internet Information Services (IIS)<\/b><\/p>\n<ol type=\"a\">\n<li>In Server Manager, select\u00a0<b class=\"ocpUI\">Add Roles<\/b>.<\/li>\n<li>On the Before you begin page in the Add Roles Wizard, select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>On the Select Installation Type page, select\u00a0<b class=\"ocpUI\">Role-based or Feature-based installation<\/b>.<\/li>\n<li>On the Select destination server page, choose\u00a0<b class=\"ocpUI\">Select a server from the server pool<\/b>, and select the server that will be running SMTP services. Select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>On the Select Server Roles page, select\u00a0<b class=\"ocpUI\">Web Server (IIS)<\/b>, and then select\u00a0<b class=\"ocpUI\">Next<\/b>. If a page that requests additional features is displayed, select\u00a0<b class=\"ocpUI\">Add Features<\/b>\u00a0and then select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>On the Select Role Services page, make sure that Basic Authentication under Security is selected, and then select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>On the Confirm Installation Steps page, select\u00a0<b class=\"ocpUI\">Install<\/b>.<br \/>\n<b class=\"ocpLegacyBold\" style=\"font-size: 1rem;\"><br \/>\nInstall SMTP<\/b><\/p>\n<ol type=\"a\">\n<li>Open Server Manager and select\u00a0<b class=\"ocpUI\">Add Roles and Features<\/b>.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">Server Selection\u00a0<\/b>and make sure that the server that will be running the SMTP server is selected and then select Features.<\/li>\n<li>On the Select Features screen, choose\u00a0<b class=\"ocpUI\">SMTP Server<\/b>. You may be prompted to install additional components. If that\u2019s the case, select\u00a0<b class=\"ocpUI\">Add Required Features<\/b>\u00a0and select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>\n<p class=\"\">Select\u00a0<b class=\"ocpUI\">Install<\/b>. After the installation is finished, you may have to start the SMTP service by using the Services snap-in for the Microsoft Management Console (MMC).<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li>2008 R2 Server<br \/>\n<b class=\"ocpLegacyBold\"><img loading=\"lazy\" class=\"alignright wp-image-168 size-full\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/feba8b31c7d171637c65f646e48c521d.png\" alt=\"\" width=\"250\" height=\"200\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/feba8b31c7d171637c65f646e48c521d.png 250w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/feba8b31c7d171637c65f646e48c521d-100x80.png 100w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/>Install Internet Information Services (IIS)<\/b><\/p>\n<ol type=\"a\">\n<li>In Server Manager, select\u00a0<b class=\"ocpUI\">Add Roles<\/b>.<\/li>\n<li>On the Before you begin page in the Add Roles Wizard, select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>On the Select Server Roles page, select\u00a0<b class=\"ocpUI\">Web Server (IIS)<\/b>\u00a0and select\u00a0<b class=\"ocpUI\">Install<\/b>.<\/li>\n<li>Select Next until you get to the Select Role Services page.<\/li>\n<li>In addition to what is already selected, make sure that\u00a0<b class=\"ocpUI\">ODBC Logging, IIS Metabase Compatibility, and IIS 6 Management Console\u00a0<\/b>are selected and then select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>When you\u2019re prompted to install IIS, select Install. You may need to restart the server after the installation is finished.<b class=\"ocpLegacyBold\">Install SMTP<\/b>\n<ol type=\"a\">\n<li>Open Server Manager and select\u00a0<b class=\"ocpUI\">Add Roles and Features<\/b>.<\/li>\n<li>On the Select Features screen, choose\u00a0<b class=\"ocpUI\">SMTP Server<\/b>. You may be prompted to install additional components. If that\u2019s the case, select\u00a0<b class=\"ocpUI\">Add Required Features<\/b>\u00a0and select\u00a0<b class=\"ocpUI\">Next<\/b>.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">Install<\/b>. After the installation is finished, you may have to start the SMTP service by using the Services snap-in for the Microsoft Management Console (MMC).<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li>Windows 10 \/ 8 \/ 7Use the instructions on\u00a0<a href=\"https:\/\/www.howtogeek.com\/112455\/how-to-install-iis-8-on-windows-8\/\">https:\/\/www.howtogeek.com\/112455\/how-to-install-iis-8-on-windows-8\/<\/a><br \/>\nYou&#8217;re probably oing to need at least the &#8216;Professional&#8217; version of the operating system to be able to pull this one off.<\/li>\n<\/ol>\n<h2>Configuring the SMTP Service for use with O365<\/h2>\n<ol type=\"1\">\n<li><b class=\"ocpLegacyBold\">Set up SMTP<\/b>\n<ol type=\"a\">\n<li>Select\u00a0<b class=\"ocpUI\">Start &gt; Administrative Tools &gt; Internet Information Services (IIS) 6.0<\/b>.<\/li>\n<li>Expand the current server, right-click the\u00a0<b class=\"ocpUI\">SMTP Virtual Server<\/b>, and then select\u00a0<b class=\"ocpUI\">Properties<\/b>.<\/li>\n<li>On the General tab, select\u00a0<b class=\"ocpUI\">Advanced &gt; Add<\/b>.<\/li>\n<li>In the IP Address box, specify the address of the server that\u2019s hosting the SMTP server.<\/li>\n<li>In the Port box, enter\u00a0<b class=\"ocpUI\">587<\/b>\u00a0and select\u00a0<b class=\"ocpUI\">OK<\/b>.<\/li>\n<li>On the Access tab, do the following:\n<ol type=\"i\">\n<li>Select Authentication and make sure that\u00a0<b class=\"ocpUI\">Anonymous Access<\/b>\u00a0is selected.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">Connection &gt; Only the List Below<\/b>, and then specify the IP addresses of the devices that will be connecting to the SMTP server, such as printers.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">Relay &gt; Only the List Below<\/b>, and then specify the IP address of the devices relaying through this SMTP server<\/li>\n<\/ol>\n<\/li>\n<li>On the Delivery tab, select\u00a0<b class=\"ocpUI\">Outbound Security<\/b>, and then do the following:\n<ol type=\"i\">\n<li>Select\u00a0<b class=\"ocpUI\">Basic Authentication<\/b>.<\/li>\n<li>Enter the credentials of the Office 365 user who you want to use to relay SMTP mail.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">TLS Encryption<\/b>.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">Outbound Connections<\/b>\u00a0and in the TCP Port box, enter\u00a0<b class=\"ocpUI\">587<\/b>\u00a0and select\u00a0<b class=\"ocpUI\">OK<\/b>.<\/li>\n<li>Select\u00a0<b class=\"ocpUI\">Advanced<\/b>\u00a0and specify\u00a0<b class=\"ocpUI\">SMTP.office365.com<\/b>\u00a0as the Smart Host.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h3><b class=\"ocpLegacyBold\"><span style=\"text-decoration: underline; color: #ff0000;\">\/!\\<\/span> Restart the IIS service and the SMTP service.\u00a0\u00a0<span style=\"text-decoration: underline; color: #ff0000;\">\/!\\<\/span><\/b><\/h3>\n<p>&nbsp;<\/p>\n<h2>Actually testing, before applying<\/h2>\n<p class=\"\">You can test SMTP relay services without using your software that needed it in the first place.<\/p>\n<p>To test SMTP relay services, use the following steps.<\/p>\n<ol type=\"1\">\n<li>Create a text file using Notepad or another text editor. The file should contain the following code. <strong>Replace the source and destination email addresses with the addresses you will use to relay SMTP<\/strong>.<code class=\"ocpCode\"><\/code>\n<pre>FROM: &lt;source email address&gt;\r\nTO: &lt;destination email address&gt;\r\nSUBJECT: Test email\r\n\r\nThis is a test email sent from my SMTP server\r\n<\/pre>\n<\/li>\n<li>Save the text file as Email.txt.<\/li>\n<li><strong>Copy<\/strong> the Email.txt file into the following folder: <strong>C:\\InetPub\\MailRoot\\Pickup.<\/strong><br \/>\nTry to copy it instead of just moving it. The mail file will disappear.<\/li>\n<li>After a short time, the file should automatically be moved to the <strong>C:\\InetPub\\MailRoot\\Queue<\/strong> folder. When the SMTP server delivers the mail, the file is automatically deleted from the local folder.\n<div class=\"ocpAlert\">\n<p class=\"ocpAlertSection\"><b class=\"ocpWarning\">Warning:<\/b>\u00a0If the SMTP server can\u2019t deliver the message, a non-delivery report (NDR) is created in the <strong>C:\\InetPub\\MailRoot\\BadMail<\/strong> folder. You can use this NDR to diagnose delivery issues.<\/p>\n<\/div>\n<p>&nbsp;<\/li>\n<\/ol>\n<h2>Troubleshooting<\/h2>\n<p>This is where most guides fall short.<\/p>\n<ol>\n<li>Read the mails, that appear in the Badmail folder.Usually there will be a reason for refusal or non-delivery explained in these files.<br \/>\nIf you have &#8216;show file extensions&#8217; turned on, they will appear as .BAD files.<br \/>\nOpen with Notepad or a similar pogram to see something like this :<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-164\" style=\"font-size: 1rem;\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/20140122005105.jpg\" alt=\"\" width=\"524\" height=\"108\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/20140122005105.jpg 524w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/20140122005105-300x62.jpg 300w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><br \/>\nSelf-explanatory, I guess.<\/li>\n<li>If mails were to actually arrive at their destinaton, but marked as &#8220;<strong>phishing<\/strong>&#8221; or appear in the <strong>spam folder<\/strong> of your recipient, chances are pretty high, your software package is still sending out through the wrong outgoing mailserver.<br \/>\nSeeing as I&#8217;m not a psychic, I can&#8217;t know how to configure outgoing mail in every piece of software.<strong>Press F1\u00a0<img loading=\"lazy\" class=\"alignright wp-image-165 size-thumbnail\" src=\"http:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/function-Key-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" srcset=\"https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/function-Key-150x150.jpg 150w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/function-Key-300x300.jpg 300w, https:\/\/zupertails.be\/wur\/wp-content\/uploads\/2018\/04\/function-Key.jpg 346w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/strong><\/p>\n<p>An other reason for your mails being marked as &#8220;phising&#8221; (and I deliberately left this near the end of this article), is also related to the above (still sending out through your ISP&#8217;s SMTP server using an Office 365 mail address).<br \/>\n<strong>HOWEVER&#8230;<\/strong><\/p>\n<p>When the mail arrives &#8211; even though its marked as spam &#8211;\u00a0 this means your ISP was able to actually deliver it. In Office 365 cases, this usually means that your ISP is not allowed to send out as your O365-linked domain name.<br \/>\nI&#8217;ll provide a detailed how-to on <a href=\"https:\/\/testconnectivity.microsoft.com\/MHA\/Pages\/mha.aspx\">interpreting mail headers<\/a> in a later post, but for the purpose of this exercise, let&#8217;s presume the mails are being marked because of the above.<\/p>\n<p>In this case, just adding\/editing an SPF record that relates to your ISP will be enough.<\/p>\n<p>I hear a couple of muffled hillbilly-sounding voices in the background asking me &#8216;what in tarnation is an SPF record&#8217; and how does that work ?<br \/>\nRead and weep :\u00a0<a href=\"https:\/\/blog.returnpath.com\/how-to-explain-spf-in-plain-english\/\">https:\/\/blog.returnpath.com\/how-to-explain-spf-in-plain-english\/<\/a><\/p>\n<p>For all you Belgians out there, these are the values you need to include in your SPF record for the bigger ISP&#8217;s :<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Telenet<\/strong> <\/span><br \/>\n<em>\u00a0 \u00a0 \u00a0 include:_spf.telenet-ops.be<\/em><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Proximus<\/strong> <\/span><br \/>\n<em>\u00a0 \u00a0 \u00a0 include:ispmail.spf.secure-mail.be <\/em><br \/>\n<em>\u00a0 \u00a0 \u00a0 include:bgc.spf.secure-mail.be<\/p>\n<p><\/em><span style=\"font-size: 1rem;\">The somewhat attentive reader might be asking himself &#8216;if I could just add an SPF record using the records for my ISP, then why did I even bother reading this article ?<\/p>\n<p><\/span><span style=\"font-size: 1rem;\">I&#8217;ll keep the answer very simple : EVERY user of this ISP will have the ability to send mail as your domain name, without passing some form of verification in this case.<\/p>\n<p><\/span><span style=\"font-size: 1rem;\">AAaaaaand we&#8217;re back to the 80&#8217;s\/90&#8217;s , where it was common fun and games to change your mail address in Outlook Express or other old mail software.<\/p>\n<p><\/span><strong style=\"font-size: 1rem;\">Random :<br \/>\n<\/strong><span style=\"font-size: 1rem;\">Did you know that Outlook Express&#8217; executable file\u00a0 \u00a0<\/span><em style=\"font-size: 1rem;\">msimn.exe<\/em><span style=\"font-size: 1rem;\"> was named, because it&#8217;s short for <\/span><em style=\"font-size: 1rem;\">MicroSoft Internet Mail and News<\/em><span style=\"font-size: 1rem;\"> ?<\/p>\n<p><\/span><\/li>\n<li>Mail does not arrive and the NDR gives an authentication error :\n<p>Did you change your O365 password for the account that you use to authenticate for the SMTP connection ?<br \/>\nYes you did. (or you just made a typo)<\/li>\n<li>Mail does not arrive and the NDR gives a &#8216;does not permit to send as&#8217; error :\n<p>Most often, this occurs when not sending as the account that is the SMTP relayer.<br \/>\nYour fancy 80&#8217;s software probably sends as (<em>e.g., which is latin for <a class=\"new\" title=\"exempli grati\u0101 (de pagina bestaat niet)\" href=\"https:\/\/nl.wiktionary.org\/w\/index.php?title=exempli_grati%C4%81&amp;action=edit&amp;redlink=1\">exempli grati\u0101<\/a>\u00a0and is often translated as example given &#8211; just sayin&#8217;<\/em>) invoicing@shortstraw.be, while your SMTP&#8217;er is oliver@shortstraw.be.<\/p>\n<p>To solve this, either change your outgoing mail address in your 80&#8217;s software, change the authenticating O365 in your SMTP relay server OR&#8230;. *drumrolls* add &#8216;send as&#8217; permissions to the invoicing mailbox for Oliver&#8217;s account.<\/p>\n<p>What&#8217;s that ? invoicing@shortstraw.be does not exist in your O365 tenant ?<br \/>\nYeah&#8230; I figured as much&#8230;<br \/>\nAdd is as an alias to Oliver&#8217;s box or create a new box. Choice is yours.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Oh, and in a footnote : you will not find the mails sent through your relay&#8217;er in the resp. mailbox&#8217; Sent Items.<br \/>\nHandy for troubleshooting&#8230; NOT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Antique software ? No TLS\/SSL support for outgoing mail ? No problem ! If you stumble upon this article through a Google search (who uses Bing, anyway&#8230;), you&#8217;re probably wondering how to solve the following issue (or something similar) : You have this old invoicing software that doesn&#8217;t get updates<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,6,9],"tags":[12,10,18,17],"_links":{"self":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts\/163"}],"collection":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=163"}],"version-history":[{"count":3,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":171,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=\/wp\/v2\/posts\/163\/revisions\/171"}],"wp:attachment":[{"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zupertails.be\/wur\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}