Edgewall Software

Extension Point : IEmailSender

InterfaceIEmailSenderSince0.12
Moduletrac.notificationSourceapi.py

The IEmailSender will be called by the notification system to send notification emails.

Purpose

Responsibilities of the interface are to implement a mechanism to send emails. Some implementations, see below, might do this by interfacing to an external email server or application. This also includes detecting and logging any problems with this external system when sending emails.

Usage

Implementing the interface follows the standard guidelines found in TracDev/ComponentArchitecture and of course TracDev/PluginDevelopment.

Only the one email_sender configured in the environment's TracIni notification section will be used by the notification system to send notification emails.

Examples

The following example uses a hypothetical webmail API to send notification emails.

from trac.core import implements, Component
from trac.notification import IEmailSender

from hypothetical.webmail.api import webmail

class SampleEmailSender(Component):

    implements(IEmailSender)

    # IEmailSender methods

    def send(self, from_addr, recipients, message):
        self.log.info("Sending notification through %s webmail to %s"
                      % (webmail.provider, recipients))
        err = webmail.send(from_addr, recipients, message)
        if err:
          self.log.info("Webmail failed: %s"
                      % err)

Available Implementations

Additional Information and References

Last modified 10 years ago Last modified on Dec 6, 2014, 12:24:20 PM
Note: See TracWiki for help on using the wiki.