2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-11 15:34:15 +00:00

Improved error handling for email support (#4862)

* Improved error handling for email support

- Prevent email sending if email not configured
- Check for tx email address before sending

(cherry picked from commit de541f811ede030ea5eb3136132731e1dafccc31)

* Update InvenTree/email.py

Co-authored-by: Matthias Mair <code@mjmair.com>

* Update InvenTree/email.py

Co-authored-by: Matthias Mair <code@mjmair.com>

* Fix location of file email.py

* Allow dummy emails in testing

* Provide default email in testing mode

* Fix to get test working

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
Oliver
2023-05-24 07:33:31 +10:00
committed by GitHub
parent 96b7845d84
commit 91d79dc3ed
6 changed files with 90 additions and 59 deletions

View File

@ -7,6 +7,7 @@ import requests
from allauth.account.models import EmailAddress
import common.models
import InvenTree.email
import InvenTree.helpers
import InvenTree.tasks
from plugin import InvenTreePlugin, registry
@ -115,7 +116,7 @@ class InvenTreeCoreNotificationsPlugin(SettingsContentMixin, SettingsMixin, Inve
if instance_title:
subject = f'[{instance_title}] {subject}'
InvenTree.tasks.send_email(subject, '', targets, html_message=html_message)
InvenTree.email.send_email(subject, '', targets, html_message=html_message)
return True