def send_mail(self, message, dest_addr, source_addr, subject):
        mailhost = getToolByName(aq_inner(self.context), "MailHost")
        if not mailhost:
            raise ComponentLookupError, 'You must have a Mailhost utility to \
execute this action'

        urltool = getToolByName(aq_inner(self.context), "portal_url")
        portal = urltool.getPortalObject()
        email_charset = portal.getProperty('email_charset')
        logger.info('sending to: %s' % dest_addr)
        try:
            # sending mail in Plone 4
            mailhost.send(message,
                          mto=dest_addr,
                          mfrom=source_addr,
                          subject=subject,
                          charset=email_charset)
        except:
            #sending mail in Plone 3
            mailhost.secureSend(message,
                                dest_addr,
                                source_addr,
                                subject=subject,
                                subtype='plain',
                                charset=email_charset,
                                debug=False)

        return True
def to_1100(context):
    """
    """
    logger.info('Upgrading collective.singingnotify to version 1.1.0')
    storage = getUtility(IRuleStorage)
    for rule in storage.values():
        for action in rule.actions:
            if IUnsubscribeNotifyAction.providedBy(action) and\
               rule.event == IIntIdRemovedEvent:
                rule.event = IConfirmUnsubscriptionEvent
    logger.info('Updated registered rules')
    def send_mail(self, message, dest_addr, source_addr, subject):
        mailhost = getToolByName(aq_inner(self.context), "MailHost")
        if not mailhost:
            raise ComponentLookupError, 'You must have a Mailhost utility to \
execute this action'
        urltool = getToolByName(aq_inner(self.context), "portal_url")
        portal = urltool.getPortalObject()
        email_charset = portal.getProperty('email_charset')
        logger.info('sending to: %s' % dest_addr)
        try:
            # sending mail in Plone 4
            mailhost.send(message, mto=dest_addr, mfrom=source_addr,
                    subject=subject, charset=email_charset)
        except:
            #sending mail in Plone 3
            mailhost.secureSend(message, dest_addr, source_addr,
                    subject=subject, subtype='plain',
                    charset=email_charset, debug=False)

        return True