mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-31 15:23:02 +00:00 
			
		
		
		
	Allow kindle_email to be CSV to allow sending to multiple kindles
This commit is contained in:
		| @@ -109,8 +109,10 @@ def convert_book_format(book_id, calibrepath, old_book_format, new_book_format, | |||||||
|  |  | ||||||
|  |  | ||||||
| def send_test_mail(kindle_mail, user_name): | def send_test_mail(kindle_mail, user_name): | ||||||
|  |     for email in kindle_mail.split(','): | ||||||
|  |         email = email.strip() | ||||||
|         WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web test e-mail'), None, None, |         WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web test e-mail'), None, None, | ||||||
|                      config.get_mail_settings(), kindle_mail, _(u"Test e-mail"), |                          config.get_mail_settings(), email, _(u"Test e-mail"), | ||||||
|                                               _(u'This e-mail has been sent via Calibre-Web.'))) |                                               _(u'This e-mail has been sent via Calibre-Web.'))) | ||||||
|     return |     return | ||||||
|  |  | ||||||
| @@ -217,8 +219,10 @@ def send_mail(book_id, book_format, convert, kindle_mail, calibrepath, user_id): | |||||||
|             converted_file_name = entry.name + '.' + book_format.lower() |             converted_file_name = entry.name + '.' + book_format.lower() | ||||||
|             link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) |             link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) | ||||||
|             email_text = _(u"%(book)s send to Kindle", book=link) |             email_text = _(u"%(book)s send to Kindle", book=link) | ||||||
|  |             for email in kindle_mail.split(','): | ||||||
|  |                 email = email.strip() | ||||||
|                 WorkerThread.add(user_id, TaskEmail(_(u"Send to Kindle"), book.path, converted_file_name, |                 WorkerThread.add(user_id, TaskEmail(_(u"Send to Kindle"), book.path, converted_file_name, | ||||||
|                              config.get_mail_settings(), kindle_mail, |                                  config.get_mail_settings(), email, | ||||||
|                                  email_text, _(u'This e-mail has been sent via Calibre-Web.'))) |                                  email_text, _(u'This e-mail has been sent via Calibre-Web.'))) | ||||||
|             return |             return | ||||||
|     return _(u"The requested file could not be read. Maybe wrong permissions?") |     return _(u"The requested file could not be read. Maybe wrong permissions?") | ||||||
| @@ -644,14 +648,15 @@ def check_username(username): | |||||||
|     return username |     return username | ||||||
|  |  | ||||||
|  |  | ||||||
| def valid_email(email): | def valid_email(emails): | ||||||
|  |     for email in emails.split(','): | ||||||
|         email = email.strip() |         email = email.strip() | ||||||
|         # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation |         # 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])?)*$", |         if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", | ||||||
|                          email): |                          email): | ||||||
|             log.error(u"Invalid e-mail address format") |             log.error(u"Invalid e-mail address format") | ||||||
|             raise Exception(_(u"Invalid e-mail address format")) |             raise Exception(_(u"Invalid e-mail address format")) | ||||||
|     return email |     return emails | ||||||
|  |  | ||||||
| # ################################# External interface ################################# | # ################################# External interface ################################# | ||||||
|  |  | ||||||
|   | |||||||
| @@ -90,11 +90,13 @@ class TaskConvert(CalibreTask): | |||||||
|                 # todo: figure out how to incorporate this into the progress |                 # todo: figure out how to incorporate this into the progress | ||||||
|                 try: |                 try: | ||||||
|                     EmailText = _(u"%(book)s send to Kindle", book=escape(self.title)) |                     EmailText = _(u"%(book)s send to Kindle", book=escape(self.title)) | ||||||
|  |                     for email in self.kindle_mail.split(','): | ||||||
|  |                         email = email.strip() | ||||||
|                         worker_thread.add(self.user, TaskEmail(self.settings['subject'], |                         worker_thread.add(self.user, TaskEmail(self.settings['subject'], | ||||||
|                                                                self.results["path"], |                                                                self.results["path"], | ||||||
|                                                                filename, |                                                                filename, | ||||||
|                                                                self.settings, |                                                                self.settings, | ||||||
|                                                            self.kindle_mail, |                                                                email, | ||||||
|                                                                EmailText, |                                                                EmailText, | ||||||
|                                                                self.settings['body'], |                                                                self.settings['body'], | ||||||
|                                                                internal=True) |                                                                internal=True) | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ | |||||||
|         </div> |         </div> | ||||||
|     {% endif %} |     {% endif %} | ||||||
|     <div class="form-group"> |     <div class="form-group"> | ||||||
|       <label for="kindle_mail">{{_('Send to Kindle E-mail Address')}}</label> |       <label for="kindle_mail">{{_('Send to Kindle E-mail Address. Use comma to seperate emails for multiple kindles.')}}</label> | ||||||
|       <input type="email" class="form-control" name="kindle_mail" id="kindle_mail" value="{{ content.kindle_mail if content.kindle_mail != None }}"> |       <input type="email" class="form-control" name="kindle_mail" id="kindle_mail" value="{{ content.kindle_mail if content.kindle_mail != None }}"> | ||||||
|     </div> |     </div> | ||||||
|     {% if not content.role_anonymous() %} |     {% if not content.role_anonymous() %} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 gjutras
					gjutras