How to use the mailmerge.api function in mailmerge

To help you get started, we’ve selected a few mailmerge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awdeorio / mailmerge / tests / test_simple.py View on Github external
def test(self):
        """A basic test using the default options"""
        # pylint: disable=no-self-use

        # Run executable on sample input files
        mailmerge.api.main(
            database_filename="test_simple.database.csv",
            template_filename="test_simple.template.txt",
            config_filename="server_dummy.conf",
            dry_run=True,
            no_limit=True,
        )
github awdeorio / mailmerge / tests / test_markdown.py View on Github external
def test_markdown(self):
        """Markdown messages should be converted to HTML before being sent."""
        mailmerge.api.main(
            database_filename=self.DATABASE_FILENAME,
            config_filename=self.SERVER_CONFIG_FILENAME,
            template_filename="test_markdown.template.txt",
            no_limit=False,
            dry_run=False,
        )

        # Check SMTP server after
        self.assertEqual(self.smtp.msg_from, "Bob ")
        recipients = ["myself@mydomain.com"]
        self.assertEqual(self.smtp.msg_to, recipients)

        # Check that the message is multipart and contains HTML text.
        message = email.parser.Parser().parsestr(self.smtp.msg)
        self._validate_message_contents(message)
github awdeorio / mailmerge / tests / test_send_attachment.py View on Github external
def test_send_attachment(self):
        """Attachments should be sent as part of the email."""
        mailmerge.api.main(
            database_filename=self.DATABASE_FILENAME,
            config_filename=self.SERVER_CONFIG_FILENAME,
            template_filename="test_send_attachment.template.txt",
            no_limit=False,
            dry_run=False,
        )

        # Check SMTP server after
        self.assertEqual(self.smtp.msg_from, "My Self ")
        recipients = ["myself@mydomain.com"]
        self.assertEqual(self.smtp.msg_to, recipients)

        # Check that the message is multipart
        message = email.parser.Parser().parsestr(self.smtp.msg)
        self._validate_message_contents(message)
github awdeorio / mailmerge / tests / test_cc_bcc.py View on Github external
def test_cc_bcc(self):
        """CC recipients should receive a copy."""
        mailmerge.api.main(
            database_filename=self.DATABASE_FILENAME,
            config_filename=self.SERVER_CONFIG_FILENAME,
            template_filename="test_cc_bcc.template.txt",
            dry_run=False,
            no_limit=False,
        )

        # Check SMTP server after
        self.assertEqual(self.smtp.msg_from, "My Self ")
        recipients = ["myself@mydomain.com",
                      "mycolleague@mydomain.com",
                      "secret@mydomain.com"]
        self.assertEqual(self.smtp.msg_to, recipients)

        # Make sure BCC recipients are *not* in the message
        self.assertNotIn("BCC", self.smtp.msg)
github awdeorio / mailmerge / tests / test_utf8.py View on Github external
def test_uft8(self):
        """Input email template with UTF8."""
        # pylint: disable=no-self-use

        # Run executable on sample input files
        mailmerge.api.main(
            database_filename="test_utf8.database.csv",
            template_filename="test_utf8.template.txt",
            config_filename="server_dummy.conf",
            dry_run=False,
        )