diff --git a/cps/helper.py b/cps/helper.py index f4c226a6c..a1d282759 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -117,9 +117,11 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format, # Texts are not lazy translated as they are supposed to get send out as is def send_test_mail(ereader_mail, user_name): - WorkerThread.add(user_name, TaskEmail(_('Calibre-Web Test Email'), None, None, - config.get_mail_settings(), ereader_mail, N_("Test Email"), - _('This Email has been sent via Calibre-Web.'))) + for email in ereader_mail.split(','): + email = email.strip() + WorkerThread.add(user_name, TaskEmail(_('Calibre-Web Test Email', None, None, + config.get_mail_settings(), email, N_("Test Email"), + _('This Email has been sent via Calibre-Web.')))) return @@ -225,9 +227,11 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id) converted_file_name = entry.name + '.' + book_format.lower() link = '{}'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) email_text = N_("%(book)s send to eReader", book=link) - WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name, - config.get_mail_settings(), ereader_mail, - email_text, _('This Email has been sent via Calibre-Web.'), book.id)) + for email in ereader_mail.split(','): + email = email.strip() + WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name, + config.get_mail_settings(), email, + email_text, _('This Email has been sent via Calibre-Web.'), book.id)) return return _("The requested file could not be read. Maybe wrong permissions?") @@ -691,15 +695,16 @@ def check_username(username): return username -def valid_email(email): - email = email.strip() - # if email is not deleted - if email: - # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation - if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", - email): - log.error("Invalid Email address format") - raise Exception(_("Invalid Email address format")) +def valid_email(emails): + for email in emails.split(','): + email = email.strip() + # if email is not deleted + if email: + # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation + if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", + email): + log.error("Invalid Email address format") + raise Exception(_("Invalid Email address format")) return email diff --git a/cps/tasks/convert.py b/cps/tasks/convert.py index 868839ab4..5354dce20 100644 --- a/cps/tasks/convert.py +++ b/cps/tasks/convert.py @@ -105,17 +105,19 @@ class TaskConvert(CalibreTask): # if we're sending to E-Reader after converting, create a one-off task and run it immediately # todo: figure out how to incorporate this into the progress try: - EmailText = N_("%(book)s send to E-Reader", book=escape(self.title)) - worker_thread.add(self.user, TaskEmail(self.settings['subject'], - self.results["path"], - filename, - self.settings, - self.ereader_mail, - EmailText, - self.settings['body'], - id=self.book_id, - internal=True) - ) + EmailText = N_(u"%(book)s send to E-Reader", book=escape(self.title)) + for email in self.ereader_mail.split(','): + email = email.strip() + worker_thread.add(self.user, TaskEmail(self.settings['subject'], + self.results["path"], + filename, + self.settings, + email, + EmailText, + self.settings['body'], + id=self.book_id, + internal=True) + ) except Exception as ex: return self._handleError(str(ex)) diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index a3ead4458..bbb7a70de 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -25,7 +25,7 @@ {% endif %}
- +
{% if not content.role_anonymous() %}