Skip to content

hmif-itb/hmif-send-mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hmif-send-mail

Python package for automated mail sending

Installation

Building from source

Before building, you need to have setuptools and wheel installed:

python -m pip install --upgrade setuptools wheel

Then build the package and install the distribution. For the second command, change the version accordingly

python setup.py bdist_wheel && python -m pip install dist/sendmail-1.0.0-py3-none-any.whl

Installing from PyPi (Currently not supported)

python -m pip install sendmail

Usage example

python -m sendmail --config=template.yml --service=aws

Template example

- sender:
    name: HMIF Tech
    email: [email protected]
  specs:
  - template: TestTemplate
    recipient_data: file.csv

Template file documentation

Variable Description
sender sender object
sender.name The name of the sender shown in the email
sender.email The email for sending
specs List of spec object
spec.template The name of the template used for the email
spec.recipient_data path to a csv file containing recipient data (email, and variables to replace in the template file)

Example

Content of TestTemplate

Hello {{ fullName }}! Your verdict is: {{ verdictStatus }}

Content of data (.csv) file

The first row of the csv file must contain all variables required in the template, otherwise TemplateAndCSVNotMatchException will be raised.
It also must contain email column, otherwise EmailHeaderNotFoundException will be raised. The email column is used as the recipient's address.

email,fullName,verdictStatus
[email protected],Test Recipient,success
[email protected],Test Recipient 2,failed

Result

The following email would be sent to [email protected] from [email protected]

Hello Test Recipient! Your verdict is: success

Creating Mail Template for AWS SES

python -m sendmail --mode=create_template --service=aws --template-name=TemplateName --subject=Subject --txt=PathToTextFile --html=PathToHTMLFile
Variable
template-name Required
subject Required
txt Optional
html Optional

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages