Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • christophe 1 post 71 karma points
    Aug 24, 2017 @ 16:41
    christophe
    0

    How to change or add recipients for notifications

    Hello,

    I'm brand new in the world of Umbraco, and I would like to know how I can add recipients for notifications when a page is created, deleted, etc.

    For now, I can assume that notifications are send to the mail associate to the principal user (the one I created during installation), because if I change this email, notifications are sent to the new email.

    I would like to send notification to this user and to another mail box, but I can't find a way to do that?

    I try to find it in the documentation or forum, but I didn't find any solution.

    Could you help me?

    Regards, Christophe

  • Marcio Goularte 356 posts 1248 karma points
    Aug 25, 2017 @ 12:52
    Marcio Goularte
    0

    You can configure the default e-mail notifications in umbracosettings.config:

    /config/umbracosettings.config

    <notifications>
      <!-- the email that should be used as from mail when umbraco sends a notification -->
      <email>[email protected]</email>
    </notifications>
    

    But if you need some dynamic logic, send to specific user types or a list of fixed recipients, you will have to implement custom code subscribe the events to send the email:

    https://our.umbraco.org/documentation/reference/events/contentservice-events

    using Umbraco.Core;
    using Umbraco.Core.Events;
    using Umbraco.Core.Models;
    using Umbraco.Core.Publishing;
    using Umbraco.Core.Services;
    
    namespace My.Namespace
    {
        public class MyEventHandler : ApplicationEventHandler
        {
    
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                ContentService.Published += ContentServicePublished;     
            }            
    
            private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
            {
                foreach (var node in args.PublishedEntities)
                {
                    if (node.ContentType.Alias == "Comment")
                    {
                        SendMail(node);
                    }
                }
            }
        }
    }
    

    Note: If you need the default HTML markup, you find in the /Umbraco/Config/Lang localization file. Alias "mailBodyHtml".

    Update: This blog has an interesting implementation of notification (not tested)

    http://www.felinesoft.com/blog/replacing-umbraco-services-notification-service/

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies