Skip to main content

mail1 is an API to send emails in a single call

Project description

Mail1 is an API to send email with a single function call. For instance, we could send an email running:

import mail1

mail1.send(subject='Test',
           text='This is a test!',
           recipients='casa@sweetohm.net',
           sender='casa@sweetohm.net',
           smtp_host='smtp.orange.fr')

That’s it!

send() method

The signature of the method to send an email is the following:

send(subject, text, text_html=None, sender=None,
     recipients=[None], cc=[], bcc=[], attachments={},
     smtp_host=SMTP_HOST, smtp_port=SMTP_PORT,
     encoding=ENCODING)

The parameters are the following:

  • subject: this is the subject of the email, as a string.

  • text: this is the text of the email as a string.

  • text_html: text as HTML.

  • sender: email address of the sender of the email.

  • recipients: the list of recipients, or the recipient as a string if there is a single one (this is NOT a coma separated list).

  • cc: the list of carbon copies.

  • bcc: the list of blind carbon copies.

  • attachments: a dictionnary that gives the file name for a given attachment name.

  • smtp_host: the hostname of the email server.

  • smtp_port: the port of the email server (defaults to 25).

  • encoding: the encoding of the message.

Command line

You can also invoke this script on command line to send emails. To get help about command line parameters, type mail1 -h, which will display following help page:

mail1 [-h] -f from -r recipient -s subject -a file
           -m smtphost -e encoding message
Send an email with following:
-h            Print this help page
-f from       The mail sender
-r recipient  The mail recipient (repeat for more than one recipient)
-s subject    The mail subject
-a file       A file to attach
-m smtphost   The SMTP server host
-e encoding   The encoding to use
message       The message

Enjoy!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mail1-3.1.0.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file mail1-3.1.0.tar.gz.

File metadata

  • Download URL: mail1-3.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for mail1-3.1.0.tar.gz
Algorithm Hash digest
SHA256 f8bd9e8c4129418edbb58160d58c58a609aa56fee7e5c22b8542f46a5dab4556
MD5 c4072fe971c54963703ddd76125a0f85
BLAKE2b-256 2440f6501b5cbfcabee52028f4a5fe6f2aaad16efc7681f7bd41cdd7e4850544

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page