Extension Point : IEmailSender
Interface | IEmailSender | Since | 0.12 |
Module | trac.notification | Source | api.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
- trac.notification.SmtpEmailSender
This is the email sender that will use Python's standard smtplib module and the SMTP server configured in the environment's TracIni notification section. - trac.notification.SendmailEmailSender
This is the email sender that will use a locally-installed sendmail program. The path to this program can be configured in the environment's TracIni notification section.
Additional Information and References
- API Reference
- sendmail ticket: #3870
- GnuPG encryption/signing tickets: #8294, #7488