fix: Handle email sending failure with appropriate error response
parent
4abf2bded6
commit
a9b44103d4
File diff suppressed because it is too large
Load Diff
|
|
@ -175,6 +175,8 @@ class SendMailView(View):
|
|||
msg.attach_alternative(html_content, "text/html")
|
||||
filename = f"{title}-{timezone.now().strftime('%Y%m%d%H%M%S')}.pdf"
|
||||
msg.attach(filename, pdf_bytes, "application/pdf")
|
||||
try:
|
||||
msg.send()
|
||||
|
||||
return JsonResponse({"message": "邮件发送成功"})
|
||||
except Exception as e:
|
||||
return JsonResponse({"error": _('Failed to send email: ') + str(e)})
|
||||
return JsonResponse({"message": _('Email sent successfully to ') + email})
|
||||
|
|
|
|||
Loading…
Reference in New Issue