def send_mail(self, reminder=False): # Do nothing if user opted out if not self.user.allow_invitation_mails: return template = "email/invitation.txt" if reminder: template = "email/invitation_reminder.txt" subject = gettext("[Dudel] Poll Invitation: %(title)s", title=self.poll.title) # For debugging with mail.record_messages() as outbox: with mail.connect() as conn: content = render_template(template, poll=self.poll, invitation=self, user=self.user) msg = Message(recipients=[self.user.email], subject=subject, body=content) conn.send(msg) for m in outbox: print("===========================") print("EMAIL SENT // " + m.subject) print(m.body) print("===========================")
def send_watchers(self, subject, template, **kwargs): with mail.record_messages() as outbox: with mail.connect() as conn: for watcher in self.watchers: user = watcher.user msg = Message(recipients=[user.email], subject=subject, body=render_template(template, poll=self, user=user, **kwargs)) conn.send(msg)
def send_watchers(self, subject, template, **kwargs): with mail.record_messages() as outbox: with mail.connect() as conn: for watcher in self.watchers: user = watcher.user msg = Message(recipients=[user.email], subject=subject, body=render_template(template, poll=self, user=user, **kwargs)) conn.send(msg) for m in outbox: print(m.subject) print("===========================") print(m.body) print("===========================")