Email is not being sent consistently in Kentico. No Errors in error log and those mail does not show

Anil Parmar asked on December 1, 2014 07:44

Hi All, We are facing currently some weird issue in Production environment. We are seeing some mails are not being sent consistently. It is sending 60% of mail, but skipping few of the mails with same code being executed. Don't know what's going wrong over here. I have put extra logging in mail code as info logging to record each and every steps it is executing. Just wanted to compare success versus failure events occurred. Surprisingly all the event data is same whether mails is being sent or it is not sent. It does not have any exception or any steps skipped if mail is not sent. I have looked into CMS_EMAIL table to just check if it has missed to show mail on UI email queue. Surprisingly it does not contain any record for that email.

With this findings i tried to look the kentico Sendmail method. I drilled down kentico code using resharper in MailNotification class EmailSender.SendEmail(siteName, emailMessage, true); method. Kentico internally starts separate thread to send the mail, Actual method which sends mail is as bellow and it has code that absorbs the ThreadAbortexception which we could not record. This could occur in SMTP server, these code we do not have access and it is just DLLs we are using from Kentico. This is the probable cause I can think of as of now, Let me know if any of the way you can help us out to drill down the issue further. Thanks in advance.

       private void Run()
WindowsImpersonationContext impersonationContext = (WindowsImpersonationContext) null;
impersonationContext = this.identity.Impersonate();
bool flag = this.emailsToSend == EmailMailoutEnum.OnlyAppQueue;
if (this.emailQueueApp.Count > 0)
if (!EmailHelper.IsAnySendingEnabled() || flag)
if (this.emailIds.Length > 0)
**catch (ThreadAbortException ex){}**
catch (Exception ex)
EventLogProvider.LogException("EmailEngine", "ThreadSender", ex);

Recent Answers

Brenden Kehren answered on December 1, 2014 13:47

Are the emails not being sent being sent via API or how are they being sent? Reason I ask is because you can force the email to be sent right away which bypasses the email queue.

Also know the CMS_Email table will only store records if the Email Queue option is checked. There are also a couple web.config logging options you can enable which might help troubleshoot your issue.

My past experiences with email sending issues has been 95% network related and 4.99% configuration related; had nothing to do with bad code.

0 votesVote for this answer Mark as a Correct answer

Anil Parmar answered on December 1, 2014 15:41

Email being sent using online marketing - workflow - triggers. The CMS API's are being used in action methods. CMS_Email I mentioned because we are seeing 60% of successful mail sent to user does have data in this table. Same code is executing for the same user, but for remaining one we are not able to get failure notification or any failed mail status. Not sure what happened with them. I will try the web.config logging options though.

We are having hard time to understand this issue, why it is intermittently. That's why tried to find some code flows.

Will there be any chance that due to network issue or configuration issue the threadabort exception would occur and we are not able to log that in event log?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 1, 2014 17:50

If you believe this to be a bug, you might email or call support regarding this.

There is a chance that the exception may not log to those additional logs as well but you won't know until you try.

As I mentioned before there is a lot of configuration with settings and now workflow and triggers so if any one of them are off, there is a good chance the email is never ever generated to be sent or is erroring out in some other process. You'd have to explain your setup/configuration in detail to be able to effectively troubleshoot the issue.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.