class GWApplications(Folder): implements(IGWApplications) email_sender = EmailTool('email_sender', 'Applications email sender') email_sender.mail_server_name = 'localhost' email_sender.mail_server_port = '25' _properties = ( { 'id': 'mail_from', 'mode': 'w', 'type': 'string' }, { 'id': 'admin_mail', 'mode': 'w', 'type': 'string' }, ) def __init__(self, appid, title, admin_mail, mail_from): self.id = appid self.title = title self.admin_mail = admin_mail self.mail_from = mail_from def get_user(self, uid): users = self.acl_users.findUser('uid', uid) for user in users: if user.get('uid') == uid: return user def get_user_name(self, uid): user = self.get_user(uid) if user: user_name = user.get('cn', '') return make_unicode(user_name) def get_user_email(self, uid): user = self.get_user(uid) if user: return user.get('mail', '') def send_new_application_mail(self, app): data = { 'username': make_unicode(app.application_data.get('username', '')), 'userid': app.userid, 'appurl': app.absolute_url(), 'basketurl': self.absolute_url() + '/basket_html', } mail_data = new_application_mail.render_email(**data) self.email_sender.sendEmail(mail_data['body_text'], self.admin_mail, self.mail_from, mail_data['subject'])
def setUp(self): from App.config import getConfiguration from Products.Naaya.NySite import NySite self.config = getConfiguration() self.config_patch = patch.object(self.config, 'environment', {}, create=True) self.config_patch.start() self.environ_patch = patch.dict(os.environ) self.environ_patch.start() self.portal = NySite('test') self.portal.portal_email = EmailTool('id_email_tool', 'Test email tool') self.TMP_FOLDER = tempfile.mkdtemp()
def send_action_completed_mail(mail_body, mail_from, mail_to, mail_subject): """ Calls an email sender to deliver the info message """ email_sender = EmailTool('email_sender', 'Zexpcopy email sender') mail_body = "%s \n\nHave a great day,\n%s" % (mail_body, NETWORK_NAME) email_sender.sendEmail(mail_body, mail_to, mail_from, mail_subject)
def send_export_completed_mail(mail_body, mail_from, mail_to): mail_subject = 'IG Data export completed' email_sender = EmailTool('email_sender', 'Zexpcopy email sender') email_sender.sendEmail(mail_body, mail_to, mail_from, mail_subject)