{"id":1158,"date":"2026-11-17T23:10:12","date_gmt":"2026-11-17T23:10:12","guid":{"rendered":"https:\/\/windows-vps.org\/blog\/?p=1158"},"modified":"2026-11-17T23:10:12","modified_gmt":"2026-11-17T23:10:12","slug":"iis-smtp-relay-smart-host-authentication-windows-vps","status":"publish","type":"post","link":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/","title":{"rendered":"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">An application on a Windows VPS that calls <code>SmtpClient.Send()<\/code> and receives <code>System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail<\/code> is a solved problem \u2014 but only if the relay path is built correctly. Port 25 outbound is blocked by nearly every hosting provider and by most residential ISPs, so the local SMTP server has to forward through an authenticated smart host. This article covers configuring the IIS SMTP feature, the .NET side that calls it, and the error codes you will hit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two facts to establish before changing anything. First, the IIS SMTP feature stopped being installed by default after Windows Server 2012 \u2014 it is still shipped as a feature, but it is in maintenance mode and has no UI since Windows Server 2012 R2. Second, if your provider blocks outbound 25, no amount of local configuration solves delivery; you need port 587 or 465 to a smart host, or the provider&#8217;s own relay endpoint. Test with <code>Test-NetConnection smtp.yourprovider.net -Port 587<\/code> before you write any configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the SMTP Server Feature<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On Windows Server 2016 through 2025 the feature is installed with:<\/p>\n\n\n<p class=\"wp-block-paragraph\"><code>Install-WindowsFeature SMTP-Server -IncludeManagementTools<\/code><\/p>\n\n\n<p class=\"wp-block-paragraph\">The management console (<code>inetmgr<\/code> \u2192 SMTP Server node) only appears after installing the IIS 6 Management Compatibility component, which is not installed by default. Install it explicitly if you want the GUI: <code>Install-WindowsFeature Web-Metabase, Web-Lgcy-Mgmt-Console<\/code>. Otherwise, everything below can be driven from <code>C:\\Windows\\System32\\inetsrv\\MetaBase.xml<\/code> or, more safely, from the <code>System.Web.Mail<\/code> style configuration via <code>%SystemRoot%\\System32\\inetsrv\\smtpsvc<\/code> ADSI objects.<\/p>\n\n\n<p class=\"wp-block-paragraph\">After installation, the service is <strong>SMTPSVC<\/strong> and the default drop directory is <code>C:\\inetpub\\mailroot\\Drop<\/code>. Verify it is running with <code>Get-Service SMTPSVC<\/code>; if it is stopped, the failure mode in your application is a connection-refused on 127.0.0.1:25 rather than an authentication error, which is a useful distinction when triaging.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring the Smart Host and Authentication<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The default SMTP virtual server accepts mail from any client in the local subnet and attempts direct delivery on port 25. Both defaults are wrong for a hosted VPS. You want it to accept only from 127.0.0.1 and to forward everything to an authenticated smart host.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Through the IIS 6 console: right-click the SMTP virtual server, Properties, Access tab, Relay restrictions, select &#8220;Only the list below&#8221;, add <code>127.0.0.1<\/code>, and tick &#8220;Allow all computers which successfully authenticate to relay&#8221;. On the Delivery tab, Outbound Security, choose Basic Authentication, enter the smart host credentials, and tick TLS encryption. Then Outbound Connections, set the TCP port to 587, and Advanced, set the smart host name.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Enabling TLS requires importing the smart host&#8217;s certificate chain into the local machine store, otherwise outbound connections fail with <code>454 4.7.0 Temporary authentication failure<\/code> while the credentials are perfectly valid. Export the root and intermediate certificates from a working machine and import them into <code>Cert:\\LocalMachine\\Root<\/code> and <code>Cert:\\LocalMachine\\CA<\/code> \u2014 not into CurrentUser, because SMTPSVC runs as LocalSystem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The .NET Side: Why SmtpClient Fails by Default<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>System.Net.Mail.SmtpClient<\/code> still exists in .NET 8 and .NET 9 but is marked obsolete for new development \u2014 it is not obsoleted, just discouraged in favour of MailKit. If your application already uses it, the minimal working configuration against a local relay is:<\/p>\n\n\n<p class=\"wp-block-paragraph\"><code>var client = new SmtpClient(\"127.0.0.1\", 25) { DeliveryMethod = SmtpDeliveryMethod.Network, EnableSsl = false, UseDefaultCredentials = false };<\/code><\/p>\n\n\n<p class=\"wp-block-paragraph\"><code>EnableSsl = false<\/code> is correct here because TLS terminates at the local SMTP service, between it and the smart host. Setting <code>EnableSsl = true<\/code> while pointing at 127.0.0.1 on port 25 causes a handshake failure that surfaces as a timeout after 100 seconds. Likewise, leave credentials empty when relaying through the local service \u2014 supplying them makes SMTPSVC attempt to use them for outbound auth and can override the configured smart host credentials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Error Codes and What They Mean<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SMTP response codes are more specific than most tutorials admit, and the first three digits tell you which layer failed. Reading them correctly saves hours of guessing.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Response<\/th><th>Meaning<\/th><th>Typical fix<\/th><\/tr><\/thead><tbody><tr><td>5.7.1 Client host rejected<\/td><td>Smart host does not accept your server IP<\/td><td>Register the VPS IP with the provider, or authenticate<\/td><\/tr><tr><td>5.7.57 Client not authenticated<\/td><td>Credentials missing or rejected<\/td><td>Recheck Outbound Security settings and app password<\/td><\/tr><tr><td>550 5.7.1 Relaying denied<\/td><td>Recipient not in allowed domain<\/td><td>Confirm the smart host authorises relay for that domain<\/td><\/tr><tr><td>421 4.7.0 Connection refused by remote<\/td><td>Provider blocks outbound port 25<\/td><td>Switch outbound port to 587 with STARTTLS<\/td><\/tr><tr><td>452 4.2.2 Mailbox full<\/td><td>Recipient-side quota<\/td><td>Not your problem \u2014 retry later, honour the bounce<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Enable SMTP protocol logging on the virtual server to capture the full exchange: <code>C:\\Windows\\System32\\LogFiles\\SMTPSVC1\\<\/code> holds per-day text logs with the client IP, the command sequence, and the response codes. This is the fastest way to prove whether the failure is local or remote.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SPF, DKIM, and Why Mail Lands in Spam<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Delivery succeeding is not the same as delivery being accepted. A VPS IP with no sending history has poor reputation, and a message without SPF alignment is very likely to be filtered. Add an SPF record to the sending domain&#8217;s DNS that includes the smart host&#8217;s sending infrastructure, and use a subdomain such as <code>mail.example.com<\/code> for envelope-from addresses so a reputation problem never affects your primary domain.<\/p>\n\n\n<p class=\"wp-block-paragraph\">DKIM signing is not something the IIS SMTP service does itself. Either let the smart host sign on your behalf \u2014 most transactional providers do, as long as the MAIL FROM domain is verified \u2014 or use a relay service that returns a DKIM key to publish in DNS. If you must sign locally, the SMTP service is the wrong tool and you should send directly from the application through a library like MailKit with <code>DkimSigner<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check your alignment before blaming the code. <code>nslookup -type=txt example.com 8.8.8.8<\/code> should show the SPF record, and a test message to a mailbox you control should carry <code>Authentication-Results<\/code> headers listing <code>spf=pass<\/code> and <code>dkim=pass<\/code>. Failures here are a DNS problem, not an SMTP problem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pickup Directory Mode for Offline or Batched Sending<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When the application generates mail in bursts \u2014 invoice runs, report exports \u2014 sending synchronously through SMTP adds latency to the request. Configure the SMTP service to deliver from a pickup directory instead: set the SMTP server&#8217;s mode to &#8220;Pickup directory from which to send&#8221; and point the application at <code>C:\\inetpub\\mailroot\\Pickup<\/code>. Writing a properly formatted <code>.eml<\/code> file into that folder is a single file operation, and the service handles retries and batching on its own schedule.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The trade-off is that a bad message sits in <code>mailroot\\Queue<\/code> with a corresponding <code>.bad<\/code> file, and nobody notices. Monitor queue depth with <code>Get-ChildItem C:\\inetpub\\mailroot\\Queue -Filter *.eml | Measure-Object<\/code> inside an existing health check, and alert when it exceeds zero for more than ten minutes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Replacing SMTP Service Entirely: The Modern Path<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For new applications, the honest recommendation is to skip the local SMTP service. Send over HTTPS to a transactional email API, or use MailKit to talk directly to the provider&#8217;s 587 endpoint with <code>SmtpClient.Connect(\"smtp.provider.net\", 587, SecureSocketOptions.StartTls)<\/code>. This removes an entire locally managed service, works when outbound 25 is blocked, and gives you structured delivery logs from the provider rather than text files on disk.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The one case that still justifies the local relay is a legacy application with a hard-coded <code>localhost:25<\/code> that cannot be changed. In that situation the IIS SMTP feature is a lightweight shim, and the configuration above is the minimum safe version of it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checklist Before Going Live<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Outbound 587 confirmed reachable from the VPS with <code>Test-NetConnection<\/code>.<\/li>\n<li>Relay restriction limited to 127.0.0.1; open relay verified closed with a test from an external host (expect 550 5.7.1).<\/li>\n<li>Smart host certificate chain present in <code>Cert:\\LocalMachine\\Root<\/code>.<\/li>\n<li>SPF record published, DKIM signing in place at the relay.<\/li>\n<li>Queue depth and Drop folder monitored by an existing scheduled task.<\/li>\n<li>Application configured with <code>EnableSsl = false<\/code> for localhost and no credentials.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Outbound mail is one of the few services where a misconfiguration is invisible until a customer says they never received the invoice. Our <a href=\"https:\/\/windows-vps.org\/\">Windows VPS plans<\/a> leave outbound 587 and 465 open by default, as the article on <a href=\"https:\/\/windows-vps.org\/blog\/windows-vps-security-policy-port-blocking-rules\/\">Windows VPS port blocking rules<\/a> explains.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Configure the IIS SMTP feature to relay through an authenticated smart host on port 587: relay restrictions, TLS certificate chain, SmtpClient settings, and the SMTP error codes you will actually see.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1158","post","type-post","status-publish","format-standard","hentry","category-tutorials-guides"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication - Windows VPS Blog<\/title>\n<meta name=\"description\" content=\"Configure the IIS SMTP feature to relay through an authenticated smart host on port 587: relay restrictions, TLS certificate chain, SmtpClient settings, and the SMTP error codes you will actually see.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication\" \/>\n<meta property=\"og:description\" content=\"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication\" \/>\n<meta property=\"og:url\" content=\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Windows VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-17T23:10:12+00:00\" \/>\n<meta name=\"author\" content=\"windows-vps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@myxiechengxuan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"windows-vps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/\",\"url\":\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/\",\"name\":\"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication - Windows VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\"},\"datePublished\":\"2026-11-17T23:10:12+00:00\",\"author\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\"},\"description\":\"Configure the IIS SMTP feature to relay through an authenticated smart host on port 587: relay restrictions, TLS certificate chain, SmtpClient settings, and the SMTP error codes you will actually see.\",\"breadcrumb\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/windows-vps.org\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\",\"url\":\"https:\/\/windows-vps.org\/blog\/\",\"name\":\"Windows VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/windows-vps.org\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\",\"name\":\"windows-vps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"caption\":\"windows-vps\"},\"sameAs\":[\"https:\/\/windows-vps.org\/blog\",\"https:\/\/x.com\/myxiechengxuan\"],\"url\":\"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication - Windows VPS Blog","description":"Configure the IIS SMTP feature to relay through an authenticated smart host on port 587: relay restrictions, TLS certificate chain, SmtpClient settings, and the SMTP error codes you will actually see.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/","og_locale":"en_US","og_type":"article","og_title":"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication","og_description":"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication","og_url":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/","og_site_name":"Windows VPS Blog","article_published_time":"2026-11-17T23:10:12+00:00","author":"windows-vps","twitter_card":"summary_large_image","twitter_creator":"@myxiechengxuan","twitter_misc":{"Written by":"windows-vps","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/","url":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/","name":"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication - Windows VPS Blog","isPartOf":{"@id":"https:\/\/windows-vps.org\/blog\/#website"},"datePublished":"2026-11-17T23:10:12+00:00","author":{"@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58"},"description":"Configure the IIS SMTP feature to relay through an authenticated smart host on port 587: relay restrictions, TLS certificate chain, SmtpClient settings, and the SMTP error codes you will actually see.","breadcrumb":{"@id":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/windows-vps.org\/blog\/iis-smtp-relay-smart-host-authentication-windows-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/windows-vps.org\/blog\/"},{"@type":"ListItem","position":2,"name":"IIS SMTP Service on a Windows VPS: Smart Host Relay and Authentication"}]},{"@type":"WebSite","@id":"https:\/\/windows-vps.org\/blog\/#website","url":"https:\/\/windows-vps.org\/blog\/","name":"Windows VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/windows-vps.org\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58","name":"windows-vps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","caption":"windows-vps"},"sameAs":["https:\/\/windows-vps.org\/blog","https:\/\/x.com\/myxiechengxuan"],"url":"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/"}]}},"_links":{"self":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/comments?post=1158"}],"version-history":[{"count":1,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":1161,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1158\/revisions\/1161"}],"wp:attachment":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/media?parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/categories?post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/tags?post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}