Stop sending some specific emails?

sukhwinder k asked on July 12, 2018 16:37

Is that possible to stop some specific emails in kentico like registration emails, group notification email, subscription emails etc. As currently in kentico we can stop all emails, but can we stop only some specific emails.

Recent Answers


Chris Bass answered on July 12, 2018 17:08 (last edited on July 12, 2018 17:13)

One thing that comes to mind is if you change the code-name of those email templates, it'll probably stop sending them :)

But to answer your question: many of the things that send emails, but not all, do have configurations. Settings / Configurations has "Registration requires email confirmation" - Store Configuration has settings for which ecommerce emails to send - For newsletters, if you don't set a Subscription Email Template on the newsletter, it won't send the emails. For document edits, Settings / Content / Content Management has 'Send Workflow emails'

For registrations, if I recall the web-parts that you use to sign up for those tend to have checkboxes for 'send notifications'.

Customizing User Registration Emails

For groups, it's on the Group properties:

Working with Groups

But other than that, yeah, the simplest way is probably just changing the expected code-name so it can't find the template.

0 votesVote for this answer Mark as a Correct answer

sukhwinder k answered on July 12, 2018 17:29

Thanks for the information Chris. Actually I need customize all emails from single point, where can I enable or disable specific type of email, and changing email template every time wont't work for me.

0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on July 12, 2018 17:32 (last edited on July 12, 2018 17:35)

Ah, then no, there isn't a single spot from which to enable/disable sending of each individual type of emails.

Do you expect to need to change whether or not certain emails are sending, often? I would think once you set up which emails to send, that it wouldn't change very much.

In any case, all of those various settings are accessible via the API, you could write a custom administration page that let you toggle them all as you need.

0 votesVote for this answer Mark as a Correct answer

sukhwinder k answered on July 12, 2018 17:43

Yeah, thats what I wanna know, which API's functions can be called to check, can you please specify some of them?

0 votesVote for this answer Mark as a Correct answer

Dev User answered on July 12, 2018 17:46

Check out the Settings app and do a search (in the description as well) for "email" and you should find the settings you need to either stop those sending or the email fields in which you can clear which won't allow them to be sent.

0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on July 12, 2018 18:04 (last edited on July 12, 2018 18:06)

The API calls are going to differ depending on Kentico version, but for Kentico 11:

The four keys editable in Settings are

  • CMSRegistrationEmailConfirmation (Require Email Confirmation for registrations)
  • CMSSendWorkflowEmails (Send Workflow Emails)
  • CMSPasswordExpirationEmail (Send Password Expiration Emails)
  • CMSSendAccountUnlockEmail (Send Account Unlock Emails)

For these ones CMS.DataEngine.SettingsKeyInfoProvider has the methods you need to edit them.

For newsletter subscriptions the settings are in NewsletterInfo, which you can get through CMS.Newsletters.NewsletterInfoProvider

Group notification emails are going to be a lot harder since it's based on your web parts and widgets, not on any single setting. But I can get you part of the way there - if you've got any Group Registration widgets, DocumentHelper.GetDocuments() gets you document objects, which have DocumentContent which should contain the data for any widgets - it'll be in XML format, so you'll need to query DocumentHelper for the documents containing the event registration widgets and update them yourself, probably using XML parser code. For the web parts, similarly, you'd need to edit the Template properties. Those are in CMS.PortalEngine.PageTemplateInfoProvider

1 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on July 12, 2018 18:07

I would look at global events specifically at GenerateQueueItems. Essentially you need to check if it fires when any email is being added to the email queue. I dont see such event, but you have to experiment.

The other option to explore would be email relay. Make Kentico generate an email, but not send it. You will send it yourself from a different server. Thus when you copy email to relay you can decide. The idea is to have some sort of intermediate email proxy where you can filter those you want

0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on July 12, 2018 18:32

@Peter: My understanding is GenerateQueueItems is specifically for Newsletter campaign emails queueing up ([dbo].[Newsletter_Emails]), and so it wouldn't affect other emails, even ones going through the site-email queue ([dbo].[CMS_Email])

But yeah, your final option sounds reasonable if you needed to send/not-send specific emails instead of specific types of emails. Set up your SMTP to point to some intermediary non-Kentico place, and then do something there to filter out emails. Kentico would think it's sending emails, but as a last resort, that could work.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on July 12, 2018 18:42

Chris, I don't believe myself that it is going to work for all the emails ;-) I just said that he has to check. I am just listing things he has to try. CMS_Email is the Email Queue, but it doesn't seem to have any global events.

P.S. There is the third option: trigger in sql on cms_email table to prevent insert.

0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on July 12, 2018 20:23

Ooh, that's a good third option. Hopefully it doesn't come to that though - I think they were just asking for a way to change the settings in one place, not to have full control over individual emails being sent.

0 votesVote for this answer Mark as a Correct answer

sukhwinder k answered on July 13, 2018 14:00 (last edited on July 13, 2018 14:01)

Thank you all for your responses.
I got an idea to enable/disable email template if we can have an extra field in "CMS_EmailTemplate" table. so, can we add new fields in the table? currently am not able to add fields in this.
0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on July 13, 2018 16:05 (last edited on July 13, 2018 16:41)

EDIT: See later comment - it turns out despite it saying 'The other tabs can be customized', you can't actually edit them for the core modules. Original Message: Sure can - In Modules, Emails, one of the classes is "Email Templates" and then you'd go to "Fields".

See this image

The problem then, I think, would be wiring up logic to actually use that 'enabled'/'disabled' flag. Which I think leads right back to the 'it is controlled in a lot of different places' problem as before.

0 votesVote for this answer Mark as a Correct answer

sukhwinder k answered on July 13, 2018 16:32 (last edited on July 13, 2018 16:34)

Yes chris. you got it right. But now, if you see the screenshot you send, its saying it is not customizable, so not able to add fields in it. Can you please once try at your end to add field in this table? See Here link text

0 votesVote for this answer Mark as a Correct answer

Chris Bass answered on July 13, 2018 16:36 (last edited on July 13, 2018 16:38)

EDIT: Huh. So despite the edit screen saying "The other tabs are still customizable", you're right, we can't. My bad

Hm.. Yeah, in that case, I think you're out of luck on that strategy.

0 votesVote for this answer Mark as a Correct answer

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