Skip to content

indiependente/send_mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

send_mail.py

Python email client

usage: send_mail.py [-h] [-b BATCH] [-c CREDENTIALS] [-t] [-v] [--version]
                    filename

positional arguments:
  filename              The JSON input file name - must be in the current
                        working directory

optional arguments:
  -h, --help            show this help message and exit
  -b BATCH, --batch BATCH
                        Batch mode - it will pick the first email object from
                        the input file and send <BATCH> emails. It will append
                        a counter to the subject of every email being sent.
  -c CREDENTIALS, --credentials CREDENTIALS
                        Read credentials from external file - applies those
                        credentials to every email
  -t, --threads         Split the work among threads
  -v, --verbose         Verbose output
  --version             show program's version number and exit

Supported features

  • Parallel threaded email sending
  • Batch mode
  • Multipart content
  • Read HTML from file
  • Read SMTP credentials from external file

Email object

Main email properties listed in the JSON object. Every email object is tied to the SMTP server that has to send it. SMTP account credentials: username and password.

Example emails.json file

[
	{
		"from" 		:	"me@example.com",
		"to"		:	"you@example.com",
		"subject"	:	"Hey! Email 1",
		"html_file"	:	"body1.html",
		"plaintext"	:	"I am plain text 1",
		"smtp"		:	"smtp.example.com",
		"port"		:	"587",
		"username"	:	"username",
		"password"	:	"password"
	},
	{
		"from" 		:	"me@example.com",
		"to"		:	"you@example.com",
		"subject"	:	"Hey! Email 2",
		"html_file"	:	"body2.html",
		"plaintext"	:	"I am plain text 2",
		"smtp"		:	"smtp.example.com",
		"port"		:	"587",
		"username"	:	"username",
		"password"	:	"password"
	},
	{
		"from" 		:	"me@example.com",
		"to"		:	"you@example.com",
		"subject"	:	"Hey! Email 3",
		"html_file"	:	"body3.html",
		"plaintext"	:	"I am plain text3",
		"smtp"		:	"smtp.example.com",
		"port"		:	"587",
		"username"	:	"username",
		"password"	:	"password"
	}
]

Credentials file

{
	"smtp"		:	"smtp.example.com",
	"port"		:	"587",
	"username"	:	"username",
	"password"	:	"password"
}

ToDo

  • Error checking
  • Email object encryption

Feature requests

  • Single input file for multiple emails:
    • Provide a JSON array of email objects
  • Batch mode
    • Picks the first email object of the array contained in the input file and sends N copy of that email (adds a counter to the subject)
  • External credential file

Releases

No releases published

Packages

No packages published

Languages