Exemplo n.º 1
0
    def _send(self):
        if self.config['formatted']:
            newsletter_stripped = ''.join(
                l.strip() for l in self.newsletter.splitlines())

            plaintext = 'HTML email support is required to view the newsletter.\n'
            if plexpy.CONFIG.NEWSLETTER_SELF_HOSTED and plexpy.CONFIG.HTTP_BASE_URL:
                plaintext += self._DEFAULT_BODY.format(**self.parameters)

            email_reply_msg_id = self.email_reply_msg_id if self.config[
                'threaded'] else None

            if self.email_config['notifier_id']:
                return send_notification(
                    notifier_id=self.email_config['notifier_id'],
                    subject=self.subject_formatted,
                    body=newsletter_stripped,
                    plaintext=plaintext,
                    msg_id=self.email_msg_id,
                    reply_msg_id=email_reply_msg_id)

            else:
                email = EMAIL(config=self.email_config)
                return email.notify(subject=self.subject_formatted,
                                    body=newsletter_stripped,
                                    plaintext=plaintext,
                                    msg_id=self.email_msg_id,
                                    reply_msg_id=email_reply_msg_id)
        elif self.config['notifier_id']:
            return send_notification(notifier_id=self.config['notifier_id'],
                                     subject=self.subject_formatted,
                                     body=self.body_formatted)
Exemplo n.º 2
0
    def _send(self):
        if self.config['formatted']:
            if self.email_config['notifier_id']:
                return send_notification(
                    notifier_id=self.email_config['notifier_id'],
                    subject=self.subject_formatted,
                    body=self.newsletter
                )

            else:
                email = EMAIL(config=self.email_config)
                return email.notify(
                    subject=self.subject_formatted,
                    body=self.newsletter
                )
        elif self.config['notifier_id']:
            return send_notification(
                    notifier_id=self.config['notifier_id'],
                    subject=self.subject_formatted,
                    body=self.body_formatted
                )