IIS/SMTP — emails are stuck in mailroot/Queue
I’m trying to send e-mails via SMTP within the IIS pickup directory. Unfortunately the e-mails are just going into the mailroot/queue folder and stay there. They never actually get sent.
Does anyone know why this would happen and a potential fix for the problem?
12 Answers 12
Had a similar problem with Files stuck in the queue. In IIS manager, SMTP Virtual Server > Properties > Delievery > Outbound Connections. The option for Limit number of connections to was checked and the value was 0 . So it was configured to never make any outbound connections, causing the emails to never leave the server. I unchecked the option and restarted the SMTP server and all was well.
I had this problem today.
After restarting the ‘Simple Mail Transfer Protocol (SMTP)’ service, it started to work again.
Just for the record: we had a case where the server could not resolve names anymore due to an erraneous DNS settings. The resulting behaviour was exactly the one that you described.
IISRESET fixed this for me. I believe it is similar to the solution of resetting the SMTP service since this service depends on IIS. After it restarted the mail inside C:\inetpub\mailroot\Queue started to disappear!
I ran into this issue recently. In my case, it turned out to be a problem with the DNS server definition in a network adapter (this has two for some reason unbeknownst to me). The designated DNS server was set to «127.0.0.1» instead of the normal «8.8.8.8» that is normally used on this network. I changed this to the correct value, restarted my SMTP server, and the queued emails were immediately distributed.
How I figured out that to look into the DNS definition issue:
- Used nslookup to find an mx server to test (tested 5 or 6 different ones)
- Tried to telnet to the server (every time met with a «couldn’t connect» message that made me initially think of firewall problems)
- Tried to ping the value for the tested mx server (every time met with a «couldn’t connect to host» message)
Hopefully this will help someone else, wasn’t something I’d have thought to look at initially.
In my experience, this is usually due to IIS SMTP trying to send and encountering a temporary (4xx response code) error. Have you turned on logging for the IIS SMTP service and reviewed the log? Sorry if that’s all obvious, but it’s hard to know the cause or the fix without knowing what the log shows.
I think the issue might be that there is a confusion between IPv4 and IPv6 on the system, so when you specify localhost, the default IPv6 protocol is chosen. I had the same issue today and it was fixed after localhost reference to IPv6 address in hosts was hashed out, although that might have been a coincidence (I am also setting up SVN). So here is my setup just in case:
- In IIS7 I have «Deliver to SMTP server» option enabled with localhost as my chosen server.
- In IIS6 I have access set to only 127.0.0.1, no authentication for incoming or outgoing.
I fiddled with the settings all day, so, to be honest, not sure what else could have influenced the fact that it’s working now. Hope this helps at least a little bit though.
The first place to look is the server log files. This will tell you if your server is having problems sending to specific hosts. The majority of the time this happens (in my experiences) it’s usually DNS (either on your end or remotely) that is the culprit.
The SMTP server is looking for a SMTP host/gateway to send the mail to.
If you are trying to send to localhost, then the localhost IP would be the gateway. If you are trying to send to an external email address like gmail or hotmail, you will need to add your ISP’s mail gateway as the smart host.
To set up a smart host:
- In IIS Manager, right-click the SMTP virtual server, and then click Properties.
- Click the Delivery tab, and click Advanced.
- In the Smart host box, type the name of the smart host server. You can type a string to represent a name or enter an IP address.
- If you want the SMTP service to attempt to deliver remote messages directly before forwarding them to the smart host server, select the Attempt direct delivery before sending to smart host check box. The default is to send all remote messages to the smart host, not to attempt direct delivery.
I had the same issue after switching email service from one host to another (new one is Office 365). After lots of trial and error, it finally started working by doing this:
- Add my email domain to IIS 6 as a «remote» domain. (This is the domain that is hosted in O365 and all user accounts use.)
- In IIS 6, double-click that domain; under «Route domain» select «Forward all mail to smart host» and enter your server(in my case, «smtp.office365.com»). Also check the box to «Allow incoming mail to be relayed to this domain.»
- In IIS 6, right-click the SMTP virtual server > Properties.
- General tab: Click Advanced and add your local server’s IP and port 587
- Access tab: ensure «Require TLS encryption» is checked. I had to create a domain cert in IIS 7 with the name of my email domain.
- Access tab: Add your local server IP to the «Connection» and «Relay» lists.
- Delivery tab: Outbound Security: select basic authentication, enter credentials of a valid licensed user; check the box for «TLS encryption»
- Delivery tab: Outbound Connections: Enter 587 for TCP Port
- Delivery tab: Advanced: Enter your email domain as the «Fully-qualified domain name» and your email server as the «Smart host» (again in my case smtp.office365.com).
Firewall: I’ve read that you need to open port 587 for outbound. (I didn’t because this is a VOIP server that needs its firewall off.)
Office 365: Add a «connector» under Admin > Exchange to allow your local static IP. Microsoft provides those instructions online.
Windows Server 2019 built-in SMTP server: Emails stuck in queue and “The remote server did not respond to a connection attempt” in event log
I’m setting up a new dedicated server using Windows Server 2019. It’s replacing an old one based on Windows Server 2008 R2. I have had the built-in SMTP server running on the old server with no issues. I have set up the new server to act as an SMTP server as well, using my own notes from setting up the old one, as well as double checking intructions online. Basically according to the instructions here:
The problem I’m having is that e-mail will not leave C:\inetpub\mailroot\Queue and will never reach the recipients. The Windows event log contains the following warning(s):
Event 4006, smtpsvc
«Message delivery to the host ‘204.79.197.212’ failed while delivering to the remote domain ‘hotmail.com’ for the following reason: The remote server did not respond to a connection attempt.»
The above is just an example using a Hotmail destination address. The same kind of message is received when trying to send to addresses on other domains.
- I have sent e-mail manually by using Telnet. The e-mail is created and received by the local SMTP server without issues, but doesn’t leave the queue folder.
- I have run SmtpDiag against both a Hotmail and a Gmail address. No issues. The MX records are listed as expected.
- I have used Nslookup and confirmed that the MX records are resolved.
- I have successfully connected to the Hotmail and Gmail SMTP servers using Telnet.
- I have used Wireshark and been able to see that my server only tries to access the IP address of the destination e-mail address domain, at port 25. So, for Hotmail, it simply resolves the IP address of hotmail.com (which is 204.79.197.212) and tries to open a connection to this address at port 25. This obviously fails, as there’s no SMTP server there. My server never even attempts to access the SMTP server at the address specified in the MX record.
That last item above also ties into an interesting thing that I noticed, which is that the IP address listed in the event 4006 message is not one of the IP addresses listed in the MX records. It is the IP address of the actual hotmail.com domain. So, why is it attempting to contact hotmail.com and not one of the addresses listed in the MX records?
To futher investigate, I used Telnet to send to an e-mail in one of my own domains. Sure enough, I find a 4006 event in the log saying:
«Message delivery to the host ‘[my domain’s IP]’ failed while delivering to the remote domain ‘[my domain]’ for the following reason: The connection was dropped by the remote host.»
It again appears that the SMTP server is trying to connect to my domain’s IP and port 25 and not to the address specified in the MX record.
This is as far as I’ve come. Maybe I’m misinterpreting something here, but it certainly looks like Windows’ SMTP server is trying to connect to the e-mail address’ domain directly at port 25 (ignoring MX records). Any ideas on what I might be doing wrong or perhaps how I should proceed in troubleshooting this?
EDIT: Found a work-around as well as what triggers the issue. See my answer below.
Mail stuck in SMTP queue (C:\inetpub\mailroot\Queue ) on Windows Server 2008
I have a Windows Server 2008 box with IIS7. I have added the SMTP role/feature in Server Manager. I have an asp web page that sends mail from the server to 1 or 2 support addresses over the internet.
This worked fine on our 2003 box. We have upgraded to 2008 and now mail is stuck in the queue folder.
If I go into IIS 6.0 Manger I see that the SMTP Virtual Server is started. Any ideas?
Premium Content
Premium Content
Ok I have turned on logging.
I am not sure if the support addresses are configured to receive mail from the Windows 2008 Server — I don’t have any admin access to that system.
Does a smart host get configured with MX records on the internet like a regular mail server? Maybe the old server had a smart host on it I am not sure.
> I am not sure if the support addresses are configured to receive mail from the Windows 2008 Server — I don’t have any admin access to that system.
*nod* Logging should show you pretty quick.
Smarthost is a setting within SMTP — it defines where to send mail. (It also simplifies troubleshooting outbound mail issues.) If it was set on the old server, it’ll probably be a good idea to set it to the same on the new server. Screen shot on where the setting lives attached.
I turned on logging yesterday and sent an email from the website but strangely enough there is no SMTP folder or log file in C:\Windows\System32\LogFil es. any ideas on that?
Yeah. that’s the default location (in c:\windows\system32\LogFil es\SMTPSVC 1\ .l og)
But. I’ve had enough wacky/crazy/stupid stuff happen with UAC in Windows 2008 that I’m going to suggest this — go ahead and tell it to log to a different location. Create a new directory, and make certain the system has permission to write to the directory.
And/Or .. .make certain to stop and restart the SMTP service after making changes.
ok.. i have a 64 bit OS so this makes sense.
i have added the role service, moved the logging folder to the D: partition, granted full permissions to the System account and Administrators group, restarted SMTP service and IIS, stop/started the virtual server, and telnetted from a command prompt to localhost and google.com.
both return «could not open connection to the host on port 23: connection failed» — should this be enough to create a log entry? i set the log schedule to hourly. still the log folder is empty.