Skip to main content

Repoze Sendmail

Project description

repoze.sendmail

repoze.sendmail is a fork of zope.sendmail with dependency on zope security framework removed. The idea being that in this case authorization should be handled by caller, not by this library, which simply provides a means to send email. This fork is meant to be usable with repoze.bfg and other non-Zope3 frameworks.

We have also made optional, for queued delivery, the running of the queue processor thread. We have added a console script, qp, which can process queued mail and either exit after one pass or continue to run daemonically, checking the queue periodically.

You probably want to take a look at the documentation for zope.sendmail:

http://pypi.python.org/pypi/zope.sendmail

See also src/repoze/sendmail/README.txt

Basic Tutorial

To use repoze.sendmail using the component architecture, you’ll need to add something like this to your project’s zcml:

Note that the queuePath in the queuedDelivery must exist on the filesystem. This creates two utilities, a mailer, named smtp, and a delivery, named myapp.mailer. The mailer is used by the delivery mechanism, so generally in your code you need only look up the delivery utility:

def send_email(msg):
    mailer = getUtility(IMailDelivery, 'bfgtest.mailer')
    mailer.send(sender, [recipient], msg.as_string())

The message is an instance of email.MIMEText.MIMEText:

import email.MIMEText
def create_message(sender, recipient, subject, body):
    msg = email.MIMEText.MIMEText(body.encode('UTF-8'), 'plain', 'UTF-8')
    msg["From"] = sender
    msg["To"] = recipient
    msg["Subject"] = email.Header.Header(subject, 'UTF-8')
    return msg

repoze.sendmail hooks into the transaction system and only sends queued messages on transaction commit. If you are using a framework which, like repoze.bfg, does not use transactions by default, you will need to begin and commit a transaction of your own in order for mail to be sent:

import transaction
transaction.manager.begin()
try:
    my_code_here()
    transaction.manager.commit()
except e:
    transaction.manager.abort()
    raise e

Change history

1.2 (2010-02-11)

  • Maildir storage for queue can now handle unicode passed in for message or to/from addresses.

1.1 (2009-02-24)

  • Added logging to queue processor console app.

  • Added ini config parsing to queue processor console app.

1.0.0

  • Initial release

  • Copy of zope.sendmail with dependency on security removed.

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

repoze.sendmail-1.2.tar.gz (27.3 kB view details)

Uploaded Source

File details

Details for the file repoze.sendmail-1.2.tar.gz.

File metadata

  • Download URL: repoze.sendmail-1.2.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for repoze.sendmail-1.2.tar.gz
Algorithm Hash digest
SHA256 41ab182a509a70456b2266a85555ddaaf8efcdbf00f1e1878ac4e62e4f03ba3f
MD5 271a9cc71bc6a8880403ba14033787d4
BLAKE2b-256 c7fc3206c6a5444f0ff3126663c7140eeb1926151def1a3a3243f4240b0b5ea8

See more details on using hashes here.

Supported by

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