Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.app.contentrules.actions.mail.MailActionExecutor Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 context
 element
 event

Detailed Description

The executor for this action.

Definition at line 57 of file mail.py.


Constructor & Destructor Documentation

def plone.app.contentrules.actions.mail.MailActionExecutor.__init__ (   self,
  context,
  element,
  event 
)

Definition at line 63 of file mail.py.

00063 
00064     def __init__(self, context, element, event):
00065         self.context = context
00066         self.element = element
00067         self.event = event

Here is the caller graph for this function:


Member Function Documentation

Definition at line 68 of file mail.py.

00068 
00069     def __call__(self):
00070         recipients = [str(mail.strip()) for mail in \
00071                       self.element.recipients.split(',')]
00072         mailhost = getToolByName(aq_inner(self.context), "MailHost")
00073         if not mailhost:
00074             raise ComponentLookupError, 'You must have a Mailhost utility to \
00075 execute this action'
00076 
00077         source = self.element.source
00078         urltool = getToolByName(aq_inner(self.context), "portal_url")
00079         portal = urltool.getPortalObject()
00080         email_charset = portal.getProperty('email_charset')
00081         if not source:
00082             # no source provided, looking for the site wide from email
00083             # address
00084             from_address = portal.getProperty('email_from_address')
00085             if not from_address:
00086                 raise ValueError, 'You must provide a source address for this \
00087 action or enter an email in the portal properties'
00088             from_name = portal.getProperty('email_from_name')
00089             source = "%s <%s>" % (from_name, from_address)
00090 
00091         obj = self.event.object
00092         event_title = safe_unicode(obj.Title())
00093         event_url = obj.absolute_url()
00094         message = self.element.message.replace("${url}", event_url)
00095         message = message.replace("${title}", event_title)
00096 
00097         subject = self.element.subject.replace("${url}", event_url)
00098         subject = subject.replace("${title}", event_title)
00099 
00100         for email_recipient in recipients:
00101             mailhost.secureSend(message, email_recipient, source,
00102                                 subject=subject, subtype='plain',
00103                                 charset=email_charset, debug=False,
00104                                 From=source)
00105         return True

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 64 of file mail.py.

Definition at line 65 of file mail.py.

Definition at line 66 of file mail.py.


The documentation for this class was generated from the following file: