Expose setting for sendmail failure alerts
This commit is contained in:
parent
fe4c3d4942
commit
3413d7c6f6
|
@ -15,6 +15,15 @@
|
|||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field>
|
||||
<b-checkbox name="rattail.mail.send_email_on_failure"
|
||||
v-model="simpleSettings['rattail.mail.send_email_on_failure']"
|
||||
native-value="true"
|
||||
@input="settingsNeedSaved = true">
|
||||
When sending an email fails, send another to report the failure
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
|
||||
% if request.has_perm('errors.bogus'):
|
||||
|
|
|
@ -34,6 +34,7 @@ import six
|
|||
from rattail import mail
|
||||
from rattail.db import model
|
||||
from rattail.config import parse_list
|
||||
from rattail.util import simple_error
|
||||
|
||||
import colander
|
||||
from deform import widget as dfwidget
|
||||
|
@ -283,6 +284,9 @@ class EmailSettingView(MasterView):
|
|||
{'section': 'rattail.mail',
|
||||
'option': 'record_attempts',
|
||||
'type': bool},
|
||||
{'section': 'rattail.mail',
|
||||
'option': 'send_email_on_failure',
|
||||
'type': bool},
|
||||
]
|
||||
|
||||
def toggle_hidden(self):
|
||||
|
@ -414,14 +418,17 @@ class EmailPreview(View):
|
|||
email = self.email_handler.get_email(key)
|
||||
data = email.obtain_sample_data(self.request)
|
||||
|
||||
self.email_handler.send_message(email, data,
|
||||
subject_prefix="[PREVIEW] ",
|
||||
to=[recipient],
|
||||
cc=None, bcc=None)
|
||||
|
||||
self.request.session.flash(
|
||||
"Preview for '{}' was emailed to {}".format(
|
||||
key, recipient))
|
||||
try:
|
||||
self.email_handler.send_message(email, data,
|
||||
subject_prefix="[PREVIEW] ",
|
||||
to=[recipient],
|
||||
cc=None, bcc=None)
|
||||
except Exception as error:
|
||||
self.request.session.flash(simple_error(error), 'error')
|
||||
else:
|
||||
self.request.session.flash(
|
||||
"Preview for '{}' was emailed to {}".format(
|
||||
key, recipient))
|
||||
|
||||
def preview_template(self, key, type_):
|
||||
email = self.email_handler.get_email(key)
|
||||
|
|
Loading…
Reference in a new issue