0

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

EDIT: because i didn't find a solution, i registered for a free account at SendGrid. Tested everything and received email. But when i publish the appliction I don't receive the mails. Now i'm completly lost

kenhas
  • 77
  • 1
  • 8
  • You won't get any exceptions for undeliverable messages. The email server will try a few times to deliver the message over hours or days before rejecting the message and sending back an email saying so. Did you check that account's mailbox for outbound messages? Server messages? – Panagiotis Kanavos Jan 18 '22 at 10:55
  • Just like snail mail, there's no way to know whether an email message was delivered. You can request a delivery notification from the final recipient's mail server but no email server is obliged to respond. [This related question](https://stackoverflow.com/questions/45027910/get-the-delivery-status-of-email-with-mimekit-mailkit-library) shows how to request a delivery receipt – Panagiotis Kanavos Jan 18 '22 at 11:06
  • I know i cannot catch an exception for sending mail. The log is for catching erros in the settings, like port number, authentication, ... The problem is mails get sent when debugging but not when the project is published. I assumed it was a mail problem but it's a bigger problem. When I use sendgrid, it sends the messages using the SendGrid api and the mails are received in debugging. When I publish, even the SendGrid doesn't work – kenhas Jan 25 '22 at 10:37

0 Answers0