Skip to content

chartergrowthfund/mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mailer

Setup

Expects a secret in Google Secret manager called: MAILGUN_TOKEN.

TODO: add an option to pull the token from environment as well.

Example Usages:

Sending a simple message

from mailer import Mailer


email = Mailer()
email.recipients = ["[email protected]", "[email protected]"]
email.subject = "This is the subject line"

email.send_message("This is a test message")

Sending a custom HTML message

from mailer import Mailer


email = Mailer()
email.recipients = ["[email protected]", "[email protected]"]
email.subject = "This is the subject line"

html = """
<html>
  <p> Dear Recipient,</p>
  <br>
  <p>This is a <strong>very important</strong> message.</p>
</html>
"""

email.send_html(html)

Sending from a Mailgun template

from mailer import Mailer


email = Mailer()
email.recipients = ["[email protected]", "[email protected]"]
email.cc = ["[email protected]"]
email.subject = "This is the subject line"
email.template = "mailgun_template_name"

email.template_vars = {
    "template_var1": "value1",
    "template_var2": "value2",
}
email.send_template()

Attaching files

from mailer import Mailer


email = Mailer()
email.recipients = ["[email protected]", "[email protected]"]
email.subject = "This is the subject line"
email.files(filepaths=["path_to_file/file_name.pdf"])

email.send_message("This is a test message")

About

Very simple wrapper for Mailgun API

Resources

Stars

Watchers

Forks

Languages