Send mail through SMTP with Python
.gitignore | ||
mail.py | ||
message.html | ||
README.md | ||
requirements.txt | ||
vars.py.example |
pymail
Easily send mails via SMTP and python
Installation
To install the requirements, run the following command
python -m pip install -r requirements.txt
Usage
Setup
- Copy
vars.py.example
tovars.py
- Setup
vars.py
with your credentials and config - Adapt
message.html
and save your contact list tocontacts.csv
Send mail
Just run
python mail.py
Templating
You can use the keys from your csv
directly, prepending a $
sign (case sensitive!). For example:
Hello $name, your value is $value!
would look like the following:
Hello h4xx0r, your value is 1337!
With a contacts.csv
looking like:
name | value |
---|---|
h4xx0r | 1337 |
Options
Sending behavior
Some mail servers will block the requests, if too many are sent too fast. You can use the variables to add delays:
WAIT_EVERY
the amount of mails sent at onceDELAY_SEC
the amount of seconds to wait between sending the next batch
Other options
LOGLEVEL
the logging level, set to'DEBUG'
for most outputDRY_RUN
if set toTrue
, the mails wont get sent, but the output is generated as if they would be sent. Good for testing and best to use withLOGLEVEL = 'DEBUG'