Esempio n. 1
0
    def test_cc(self):

        msg = Message(
            subject="testing", recipients=["*****@*****.**"], body="testing", cc=["*****@*****.**"]
        )

        response = msg.get_response()
        self.assertIn("Cc: [email protected]", str(response))
Esempio n. 2
0
    def run(self, testing):
        mail = Mail(app)
        for user, csv_reports in generate_reports(app.config["REPORTS_DIR"]):
            context = {"user": user}
            template = Template(app.config["EMAIL_TEXT_TEMPLATE"])
            msg = Message(app.config["EMAIL_SUBJECT_LINE"],
                          recipients=[user.alternate_email] if user.use_alternate_email else [user.email],
                          sender=app.config["DEFAULT_MAIL_SENDER"])
            msg.body = template.render(context)

            for csv_filename, csv_data in csv_reports:
                msg.attach(csv_filename, "text/csv", csv_data)
                
            if not testing:
                mail.send(msg)
            else:
                print msg.get_response().to_message().as_string()
Esempio n. 3
0
    def test_bcc(self):

        msg = Message(subject="testing",
                      recipients=["*****@*****.**"],
                      body="testing",
                      bcc=["*****@*****.**"])

        response = msg.get_response()
        assert "Bcc: [email protected]" in str(response)
Esempio n. 4
0
    def test_reply_to(self):

        msg = Message(
            subject="testing",
            recipients=["*****@*****.**"],
            sender="spammer <*****@*****.**>",
            reply_to="somebody <*****@*****.**>",
            body="testing",
        )

        response = msg.get_response()
        self.assertIn("Reply-To: somebody <*****@*****.**>", str(response))
Esempio n. 5
0
File: mail.py Progetto: UfSoft/ILog
 def get_response(self):
     response = BaseMessage.get_response(self)
     response["Date"] = datetime.utcnow().strftime(
         '%a, %d %b %Y %H:%M:%S +0000'
     ).strip()
     return response