Skip to content

Email not sending out in Umbraco 9

April 14, 2022

Welcome back, you see I haven’t posted for a long while due to transitioning with .NET work with Umbraco and if like me, you keep on receiving a lot of minor headaches with Umbraco 9 with the app settings, look no further as I have more hints and tips for this. If you get a lot of SMTP errors expecting Umbraco 9 to send emails out of the box here is why , I had checked many times with the SMTP settings in appsettings.json and it still received the following error message : –

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:80
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream()

Three reasons that error could be generated:

a) target smtp server is not running/listening on the target port;

b) target smtp server is not allowing the connection due to ip restriction;

c) a firewall is rejecting the connection to the server;

In the error message it mentions that the target service is 127.0.0.1:587. That is the mail submission port on the local host (the same host IIS web app is running on). Do you have an SMTP listener running on the local host on port 587 with it configured to allow local relay? If not then you may need to install Window’s local SMTP feature and configure it.

Refer also to https://community.spiceworks.com/topic/871311-no-connection-could-be-made-because-the-target-machine-actively-refused-it-127

In Umbraco 9, this doesn’t seem to be really useful as we are not directly working on the send email code.

Solution: Turns out that you need to modify the settings in appsettings.development.json to correct SMTP settings as its set to local out of the box! And that’s why!

From → Uncategorized

Leave a Comment

Leave a comment