Returns: List of `Message`_ objects ''' msgs = [] if multi: for to in self.to_email: msgs.append(self.build_msg(to)) else: msgs.append(self.build_msg(self.to_email)) return msgs def send(self, multi=False, async=True): '''Send a single or group of notifications Keyword Arguments: multi: If True, multi will build an individual Notification for each recipient. If False, a single Notification will be created with all of the recipients visible in the ``to`` line. async: If True, the sending will be kicked out to a Celery worker process. If False, the sending will occur on the main request thread ''' msgs = self._build(multi) if async: send_email.delay(msgs) else: send_email.run(msgs) return True
msg.attach( filename=secure_filename(attachment.filename), content_type=attachment.content_type, data=attachment.stream.read() ) return msg except Exception, e: current_app.logger.info( 'EMAILFAIL | Error: {}\nTo: {}\n:From: {}\nSubject: {}'.format( e, self.to_email, self.from_email, self.subject ) ) return False def send(self, multi=False, async=True): msgs = [] if multi: for to in self.to_email: msgs.append(self.build_msg(to)) else: msgs = self.build_msg(self.to_email) if async: send_email.delay(msgs, multi=multi) else: send_email.run(msgs, multi=multi) return True
) return msg except Exception, e: current_app.logger.info( 'EMAILFAIL | Error: {}\nTo: {}\n:From: {}\nSubject: {}'.format( e, self.to_email, self.from_email, self.subject ) ) return False def _build(self, multi=False): msgs = [] if multi: for to in self.to_email: msgs.append(self.build_msg(to)) else: msgs.append(self.build_msg(self.to_email)) return msgs def send(self, multi=False, async=True): msgs = self._build(multi) if async: send_email.delay(msgs) else: send_email.run(msgs) return True