Extension Point : IEmailSender
The IEmailSender will be called by the notification system to send notification emails.
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.
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)
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.
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.