I am hosting a .NET core 2.0 web site on Microsoft Azure and the web applications sends emails. I was able to configure the application to send emails via GMAIL, but now, I just purchased a hosted web mail solution (Email Essentials plan) with you guys. The questions are:
This is my appsettings.json configuration for that piece of logic:
The password is stored in Azure Vault. I am using MimeKit API to send the email.
On localhost, the code throws an exception when it executes this line:
client.Connect("relay-hosting.secureserver.net", 25, false);
and the exception is : System.Net.Internals.SocketExceptionFactory.ExtendedSocketException
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xx.xxx.xxx.xxx:25 where xx.xxx.xxx.xxx is a IP address that resolves to a "secureserver.net" server
Any help would be appreciated.
Solved! Go to Solution.
I found the answers I was looking for...
First, the SMTP information:
This information, along with POP and IMAP settings, is available in Office 365. Connect to your account in Office 365 and click on the Cog (Settings) icon. Type: "POP and IMAP".
Then, the appsettings.json config looks like this:
and the code that sends the email was modified to use the proper encryption:
using (var client = new SmtpClient())
One thing, the FROM must be authorized to send emails. Actually, I only have the user administrator defined. Thus, when I used a fake email address such as "firstname.lastname@example.org", the code threw an exception:
5.7.60 SMTP; Client does not have permissions to send as this sender
Hope this help someone.
setting an alias to be used in the FROM field will resolve the exception when the FROM value is not a defined user.