/mailshot

Mailshot is a wrapper around smtplib's SMTP connection and simplifying sending of email using python.

Primary LanguagePythonMIT LicenseMIT

Mailshot

Mailshot is a wrapper around smtplib's SMTP connection and simplifying sending of email using python.


Example


from mailshot import Mailshot

mailshot = Mailshot()
mailshot.compose("to@example.com", subject="Example")
mailshot.send()

Install


Run the following command

pip install mailshot

Username & Password


Usage of application specific passowrd is recommended. Store it in the environment variable. Use EMAIL for storing the Gmail address and PASSWORD for storing application-specific passwords (recommended).


If you want to store the password in the script, you can do it as follows.


from mailshot import Mailshot

mailshot = Mailshot("u@example.com", "password")

The best way to can take the password as an input.


from mailshot import Mailshot

password = input("Password : ")

mailshot = Mailshot("u@example.com", password)

If you don’t want your password to show on your screen when you type it, you can import the getpass module and use .getpass() instead for blind input of your password.


Usage


compose() method takes following arguments

  • to (required) : A string or list of strings of recipients.
  • cc (optional) : A string or list of strings of recipients of the carbon copy.
  • bcc (optional) : A string or list of strings of recipients of the blind carbon copy.
  • subject (optional) : A subject string.
  • text (optional) : A text string.
  • html (optional) : A html string to render.
  • files (optional) : A file or list of files.

Example


from mailshot import Mailshot

mailshot = Mailshot()

mailshot.compose("to@example.com", cc=["one@example.com", "two@example.com"], subject="Test Mail", text="Test Mail", files=["test.pdf", "test.png"])

Features


Mailshot allows you to

  • Send mail to bulk of recipients.
  • Send text and HTML body.
  • Send bulk of files.
  • Send the personalised email.

Author


Mailshot is developed by Rohan Pednekar.


License


Mailshot is licensed under the MIT License.


Source Code


Source code is available on GitHub at: rohan-pednekar/mailshot.


Issues


To file issue reports and feature requests use the project's issue tracker on GitHub.