<p>To confirm the behavior here, Sprout Notification Emails only get triggered on web requests and are suppressed for console requests and during updates and migrations. Notification Emails could get triggered in other contexts but you would need to do so programmatically.</p>

<h3>Notification Events don't run for console requests</h3>

<pre class="lang-php prettyprint-override"><code>$request = Craft::$app-&gt;getRequest();

// Only handle notifications on web requests
if ($request-&gt;getIsConsoleRequest()) {
    return false;
}
</code></pre>

<h3>Notification Events don't run during migrations</h3>

<pre class="lang-php prettyprint-override"><code>if ($request-&gt;getIsActionRequest()) {
    $actionSegments = $request-&gt;getActionSegments();
    if (
        ArrayHelper::firstValue($actionSegments) === 'updater' ||
        $actionSegments === ['app', 'migrate'] ||
        $actionSegments === ['pluginstore', 'install', 'migrate']
    ) {
        return false;
    }
}
</code></pre>

<p><a href="https://github.com/barrelstrength/craft-sprout-base-email/blob/v1.2.7/src/services/NotificationEmailEvents.php#L169" rel="nofollow noreferrer">Code examples</a> from Sprout Base Email v1.2.7</p>

CC BY-SA 4.0
2020-04-10T11:26:41.577Z
2020-04-10T11:26:41.577Z
Ben Parizek
<p>So I have a FeedMe task that runs and updates a custom field for a select amount of entries.</p>

<p>In my notification email, I have a custom rule like so:</p>

<pre><code>{% if object.customField | length and object.customField == 'hello' %}{{true}} {{else}} {{false}}{% endif %}
</code></pre>

<p>When I run the FeedMe task, the email doesn't get sent but I can see the entries get updated. If I go into the entries and save one manually, then the email sends so it seems that the rule works.</p>

<p>I also went in a plugin and set up the following event listener:</p>

<pre class="lang-php prettyprint-override"><code>Event::on(
    Elements::class,
    Elements::EVENT_AFTER_SAVE_ELEMENT,
    function(ElementEvent $event) {
        if ($event-&gt;element instanceof Entry) {
            $entry = $event-&gt;element;

            Craft::info('Entry being updated: ' . $entry-&gt;title, __METHOD__);
        }
    }
);
</code></pre>

<p>and after I run the FeedMe task again, I check the logs and every entry that was updated by the task is logged as being saved.</p>

<p>In conclusion, I know the entries are being updated and saved by the FeedMe task but the notification email custom rule doesn't trigger unless I manually save the entries.</p>

CC BY-SA 4.0
2019-12-20T14:26:07.357Z
I'll have to look closer at this. My initial guess would be that we are not triggering emails in the task scenario by default because they would also trigger in scenarios such as any ResaveElements task run by Craft or another plugin (say, updating an Entry Title Format and accidentally triggering an email for every entry being resaved in a Section). I will take a closer look and see if this isn't a bug but this may be a scenario where you would need to consider a custom event to target your specific scenario.
Ben Parizek
CC BY-SA 4.0
2019-12-20T14:35:20.043Z
@BenParizek Gotcha, thanks for looking into it!
Mr.Smithyyy
<plugin-sproutemail>
Saving entries with FeedMe doesn't trigger Sprout notification email
# Saving entries with FeedMe doesn't trigger Sprout notification email

(Asked by: username_0 on 2019-12-20)

So I have a FeedMe task that runs and updates a custom field for a select amount of entries.
In my notification email, I have a custom rule like so:
{% if object.customField | length and object.customField == 'hello' %}{{true}} {{else}} {{false}}{% endif %}

When I run the FeedMe task, the email doesn't get sent but I can see the entries get updated. If I go into the entries and save one manually, then the email sends so it seems that the rule works.
I also went in a plugin and set up the following event listener:
Event::on(
    Elements::class,
    Elements::EVENT_AFTER_SAVE_ELEMENT,
    function(ElementEvent $event) {
        if ($event->element instanceof Entry) {
            $entry = $event->element;

            Craft::info('Entry being updated: ' . $entry->title, __METHOD__);
        }
    }
);

and after I run the FeedMe task again, I check the logs and every entry that was updated by the task is logged as being saved.
In conclusion, I know the entries are being updated and saved by the FeedMe task but the notification email custom rule doesn't trigger unless I manually save the entries.

**Tags:** plugin-sproutemail
> **Comments:**
> **username_1**: I'll have to look closer at this. My initial guess would be that we are not triggering emails in the task scenario by default because they would also trigger in scenarios such as any ResaveElements task run by Craft or another plugin (say, updating an Entry Title Format and accidentally triggering an email for every entry being resaved in a Section). I will take a closer look and see if this isn't a bug but this may be a scenario where you would need to consider a custom event to target your specific scenario.  
> **username_0**: @BenParizek Gotcha, thanks for looking into it!  

---

## 1 answers

### Answer by username_1 on 2020-04-10. Score: 1

To confirm the behavior here, Sprout Notification Emails only get triggered on web requests and are suppressed for console requests and during updates and migrations. Notification Emails could get triggered in other contexts but you would need to do so programmatically.
Notification Events don't run for console requests
$request = Craft::$app->getRequest();

// Only handle notifications on web requests
if ($request->getIsConsoleRequest()) {
    return false;
}

Notification Events don't run during migrations
if ($request->getIsActionRequest()) {
    $actionSegments = $request->getActionSegments();
    if (
        ArrayHelper::firstValue($actionSegments) === 'updater' ||
        $actionSegments === ['app', 'migrate'] ||
        $actionSegments === ['pluginstore', 'install', 'migrate']
    ) {
        return false;
    }
}

Code examples from Sprout Base Email v1.2.7


---

