# -*- coding: utf-8 # Copyright 2006 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField, FileField, BooleanField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget, BooleanWidget from Products.Archetypes.public import BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema + Schema(( BooleanField('uselist', widget=BooleanWidget( label="Use this list", description="Check this checkbox if you want to send emails only to recipients, added in list below", label_msgid='label_help', description_msgid='help_title', i18n_domain="plone"), ), StringField('list', widget=TextAreaWidget( label="List", description="List of possible recipients", label_msgid='label_help', description_msgid='help_title', i18n_domain="plone"), ), )) class EmailMe(BaseContent): """ EmailMe product """ meta_type = "EmailMe" archetype_name = "EmailMe" global_allow = 1 allowed_content_types = [] security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/send_mail', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/base_edit', 'permissions': ('Manage Portal',), }, ) def getListAsArray(self): """get list""" return self.list.split("\n") def getDataFromForm(self, REQUEST): """ it gets all data and sends email""" address_to = REQUEST.get("address_to") address_from = REQUEST.get("address_from") subject = REQUEST.get("subject") body = REQUEST.get("body") mailhost = self.MailHost mailhost.secureSend(body,address_to,address_from,subject,charset='utf-8') registerType(EmailMe, PROJECT_NAME)