Hi
I'm searching for a simple example in order to send an email via Python (example in a cronjob).
I searched and found dozens of pages but none with a valid solution
This is my code:
_cr = openerp.registry(self.config['db_name']).cursor()
env = openerp.api.Environment(_cr, openerp.SUPERUSER_ID, {})
mail_pool = env['mail.mail']
values={}
values.update({'subject': 'Your subject'})
values.update({'email_to': 'email_to@gmail.com'})
values.update({'body_html': 'body' })
values.update({'body': 'body' })
msg_id = mail_pool.create(values)
if msg_id:
mail_pool.send([msg_id])
else:
logger.error("Error")
It's not working because
IrMailServer = env['ir.mail_server']
in "core send" function is None (obviously I've already correctly set up an Outgoing Server)Why???
Please, can you write a practical and working example?
Thank's
Pietro