Skip to main content

A module to send email simply in Python

Project description

Here are some of the features:

  • Single class to send plain text, HTML email, and attachments

  • Auto detects attachment types

  • Support for internationalized headers

Changes in version 0.3

The API for Mailer.To is changed. Use a string to specify a single recipient, and an iterable to specify more than one.

Changes in version 0.4

You can now specify the port in Mailer

from mailer import Mailer
sender = Mailer('smtp.example.com', port=20)

Changes in version 0.5

  • Message.attach takes an optional cid argument.

  • You can now send HTML emails with attachments

Thanks to Douglas Mayle for his patch for this.

Changes in version 0.6

  • Can now select port

  • Supports gmail

Changes in version 0.7

  • You can now specify MIME type:

    msg.attach("picture.png", mimetype="image/png")

Examples

Sending an HTML email:

from mailer import Mailer
from mailer import Message

message = Message(From="me@example.com",
                  To="you@example.com",
                  charset="utf-8")
message.Subject = "An HTML Email"
message.Html = """This email uses <strong>HTML</strong>!"""
message.Body = """This is alternate text."""

sender = Mailer('smtp.example.com')
sender.send(message)

Sending an attachment:

from mailer import Mailer
from mailer import Message

message = Message(From="me@example.com",
                  To=["you@example.com", "him@example.com"],
                  Subject="Cute Cat")
message.Body = """Kittens with dynamite"""
message.attach("kitty.jpg")

sender = Mailer('smtp.example.com')
sender.send(message)

Tested with Python 2.4, 2.5, and 2.6

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

mailer.0.8.0.zip (6.5 kB view details)

Uploaded Source

Built Distribution

mailer.0.8.0.win32.exe (202.0 kB view details)

Uploaded Source

File details

Details for the file mailer.0.8.0.zip.

File metadata

  • Download URL: mailer.0.8.0.zip
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mailer.0.8.0.zip
Algorithm Hash digest
SHA256 00f43be91bc4633a9c633f88e355288fb8df170e21155a7a4c5441a1739f25df
MD5 c64488ec30a09464395dff17fb21721a
BLAKE2b-256 85f329e01fc824382755107e8026c1adea4449d1e070a25f43675a5dd858e2df

See more details on using hashes here.

File details

Details for the file mailer.0.8.0.win32.exe.

File metadata

  • Download URL: mailer.0.8.0.win32.exe
  • Upload date:
  • Size: 202.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mailer.0.8.0.win32.exe
Algorithm Hash digest
SHA256 6e5e49db2b7642ba6a3a8d5bf607ca9015d218daafb1aa94bae25c2cd310df7a
MD5 8539c24d90a82506f4cbf64ce4f3c2c0
BLAKE2b-256 882332793cd57a305039ef7eb7137834cbf13d3939d9ef313af07fdf664bd670

See more details on using hashes here.

Supported by

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