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