(Migrated) New Email Service Component for Zato

(This message has been automatically imported from the retired mailing list)

I just finish a component for sending mails in Zato Services in the Zato
way, like Zato OpenERP integration it require some Redis keys to be set,
it’s based on OpenERP smtplib integration but adapted to Zato.
The way to use it is better to be showed as an example service

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function,

from zato.server.service import Service
from zato.mail import MailService

class MailServiceTest(MailService):
def handle(self):
 conn = self.mail.get('app-mail')
#parameters are the followings, for better explanation look at the source,
it has comments
#build_email(email_from, email_to, subject, body, email_cc=None,
email_bcc=None, reply_to=False, attachments=None, message_id=None,
references=None, object_id=False, subtype='plain', headers=None,
body_alternative=None, subtype_alternative='plain')
msg = conn.build_email("aekroft@gmail.com", ["aekroft@gmail.com",], "email
from zato service", "hello world from zato")

the following keys need to be added to Redis in order to this works, this
are just example keys

set zato:mail:conn-info:smtp_host:app-mail smtp.gmail.com
set zato:mail:conn-info:smtp_port:app-mail 465
set zato:mail:conn-info:smtp_user:app-mail email@gmail.com
set zato:mail:conn-info:smtp_pass:app-mail mypassword
set zato:mail:conn-info:smtp_encryption:app-mail ssl
set zato:mail:conn-info:smtp_debug:app-mail True

Where the app-mail in keys refers to the smtp connection that you want to
fetch to be used latter in a Zato Service. The values for smtp_encryption
can be any of (‘none’, ‘starttls’, ‘ssl’)

This module is a python dependency that you need to install. The way to
install this in Zato is like all the extra dependencies that you need to
use in your services, just drop it in zato_extra_paths folder of your Zato
instalation or add the paths to the zato or py files in the bin folder of
your Zato installation

Dariusz maybe this can be added to the core or labs
I hope this will be helpful, Enjoy it