- # Send an email: the recipients are the PI of the authority
- recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
-
- theme.template_name = 'slice_request_email.txt'
- text_content = render_to_string(theme.template, request)
-
- theme.template_name = 'slice_request_email.html'
- html_content = render_to_string(theme.template, request)
-
- theme.template_name = 'slice_request_email_subject.txt'
- subject = render_to_string(theme.template, request)
- subject = subject.replace('\n', '')
-
- sender = email
- msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
- print msg
- msg.attach_alternative(html_content, "text/html")
- msg.send()
- #send_mail(subject, msg, email, recipients)
+ try:
+ # Send an email: the recipients are the PI of the authority
+ recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+
+ theme.template_name = 'slice_request_email.txt'
+ text_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'slice_request_email.html'
+ html_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'slice_request_email_subject.txt'
+ subject = render_to_string(theme.template, request)
+ subject = subject.replace('\n', '')
+
+ sender = email
+ msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+ print msg
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"