.Net Core 5 - Mailkit : cannot send mail after publish
Answers to your questions / Network / .Net Core 5 - Mailkit : c...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

.Net Core 5 - Mailkit : cannot send mail after publish

by
AmirM
Created on 2022-01-31 10:50:07 (edited on 2024-09-04 14:26:18) in Network

I'm using Mailkit to send mails in my .Net Core 5 mvc application. In Visual Studio everything works fine when debugging. I receive the mails i send so i know the settings are correct. But when i publish the application to IIS, i'm no longer receiving the mail.

In my logging, everything looks fine. I'm getting that the message got sent.I'm using ovh to send the mail with these settings

try
{
await client.ConnectAsync("ssl0.ovh.net", 587, SecureSocketOptions.StartTls);
await client.AuthenticateAsync("myEmailadress", "myPassword");
await client.SendAsync(message);
await client.DisconnectAsync(true);
_log.savelog("success");
}
catch(exception ex)
{
_log.savelog("error");
}
The above settings work in Visual Studio when debugging. The log says "success". After publishing, no mail is received while the log says "success" I have no idea where to look for the problem