예제 #1
0
    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("===========================")
예제 #2
0
파일: poll.py 프로젝트: opatut/dudel
 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)
예제 #3
0
파일: poll.py 프로젝트: femtobit/dudel
    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("===========================")
예제 #4
0
    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("===========================")