Chance Posted April 22 Report Share Posted April 22 It would be nice to prevent emails being sent from system. In our particular case it is because we have some contacts that have a valid email address stored, but we know for FACT the email address is NOT a working email address. Blesta sends emails to these users not caring about the bounce-backs that will occur due to no such mailbox. Other plugin developers may have their own reason to prevent emails being sent. In reviewing the event triggers in app/models/emails.php, it would be very simple to add a variable that plugins can set to prevent email sending, or leave alone to allow emails to flow as normal. It involves changing this block of code currently in /app/models/emails.php, line #558: // Trigger the event $eventFactory = $this->getFromContainer('util.events'); $eventListener = $eventFactory->listener(); $eventListener->register('Emails.send'); $tags = array_merge( $tags, (array) $eventListener->trigger( $eventFactory->event('Emails.send', compact('action', 'options', 'tags')) )->getReturnValue() ); to this block of code (not much difference at all): // Trigger the event $abort = null; $eventFactory = $this->getFromContainer('util.events'); $eventListener = $eventFactory->listener(); $eventListener->register('Emails.send'); $event = $eventFactory->event('Emails.send', compact('action', 'options', 'tags', 'abort')); $event_result = $eventListener->trigger($event)->getReturnValue(); if( $event_result['abort'] ) { $this->Input->setErrors([ 'email' => [ 'sending_restricted' => $event_result['abort'] ] ]); return ''; } if( is_array($event_result['tags']) ) { $tags = array_merge($tags, $event_result['tags']); } The same code could also replace the current code for Emails.sendCustom event trigger. Plugins could theoritecally define their reason for stopping the email by defining a string error message in the abort parameter. I believe the abort variable would need to be handled as a possible array upon return of event in case multiple plugins define reasons to abort sending. Quote Link to comment Share on other sites More sharing options...
Paul Posted April 23 Report Share Posted April 23 @Jono What do you think of this feature request? I can see the utility in being able to filter out particular emails from being sent from a plugin. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.