Orchestrator Event Viewer:System.Net.Mail.SmtpException:Failure sending mail ->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

In Orchestrator, when trying to test mail settings, the following error is displayed:

Sending the test mail failed! SmtpStatusCode: GeneralFailure. Original message from SMTP server: Failure sending mail. (#2600)

The event viewer shows the following error:
UiPath.Orchestrator.Core.Exceptions.BadRequestException: Error code - 2600, Message - ‘Sending the test mail failed! SmtpStatusCode: GeneralFailure. Original message from SMTP server: Failure sending mail.’ —> System.Net.Mail.SmtpException: Failure sending mail. —> 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 XXXXXX

Issue Overview:

In Orchestrator, when trying to test mail settings, the following error is displayed:

Sending the test mail failed! SmtpStatusCode: GeneralFailure. Original message from SMTP server: Failure sending mail. (#2600)

The event viewer shows the following error:

UiPath.Orchestrator.Core.Exceptions.BadRequestException: Error code - 2600, Message - 'Sending the test mail failed! SmtpStatusCode: GeneralFailure. Original message from SMTP server: Failure sending mail.' ---> System.Net.Mail.SmtpException: Failure sending mail. ---> 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 XXXXXX

Root Cause:
The 2600 error is a generic error that occurs whenever an SMTP message fails. In this case, the actual error is seen in the event viewer and it shows that the problem is that the remote server is refusing the connection.

Resolution:

  1. To confirm this is the issue that is being faced, make sure to first check the event viewer logs on the Orchestrator server.
  1. Verify that the correct Port and Hostname is being used under the Orchestrator settings.
a. SMTP host – this should be the SMTP host and should be provided by the Email Servers admin. It should be the name of the SMTP mail server host.
b. SMTP Port – This is the port that the SMTP server is listening on. Verify this with the Email Server admin. Usually, it is 25 or if using SSL, it can be 587. It can also be a custom port.

  1. Verify that the SMTP host resolves to the correct IP address
a. Open up a command prompt (CMD.exe)
b. Type nslookup and hit enter
c. Type set type=MX and hit enter
d. Type the domain name and hit enter, for example: google.com
e. The results will be a list of host names that are set up for SMTP
f. If no answer is received from DNS server, there is a good chance that there is no SMTP Servers set up for that domain.

  1. Try sending a test email using powershell
a. Send-MailMessage - Microsoft.PowerShell.Utility
b. The command needs to include the SMTP host parameters:

i. i.e. Send-MailMessage -From 'User01 <user01@fabrikam.com>' -To 'User02 <user02@fabrikam.com>', 'User03 <user03@fabrikam.com>' -Subject Test Email' -Body "SMTP Test" -SmtpServer 'smtp.fabrikam.com' -Port '587' -UseSsl 'True'

c. The UseSsl parameter depends on the SMTP server. If you are unsure if it is needed, try the command with and without it.
  1. If sending an email from PowerShell works on the Orchestrator server, check that the same parameters are used in the Orchestrator GUI. If this is the case, open a ticket with the UiPath support team.
  1. If the PowerShell command fails, contact your administrator as something is misconfigured in the network or the SMTP server.