Dear Wizardz,
First you need to set Outgoing Mail Server from settings menu.
Settings > Technical > Email > Outgoing Mail Server.
or
refer below link for outgoing mail configration
http://www.odoo.yenthevg.com/configure-outgoing-mailservers/
Second write below.
def create(self, cr, uid, vals, context=None):
result = super(res_users, self).create(cr, uid, vals, context=context)
template_obj = self.pool.get('email.template')
group_model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'res.users')])[0]
body_html = '''Message whatever you want to send'''
template_data = {
'model_id': group_model_id,
'name': 'Template Name',
'subject' : 'Subject for your email',
'body_html': body_html,
'email_from' : 'from email id',
'email_to' : 'to email id',
}
template_id = template_obj.create(cr, uid, template_data, context=context)
template_obj.send_mail(cr, uid, template_id, result, force_send=True, context=context)
return result
Updated Code
class res_users(osv.Model):
_inherit = 'res.users'
def create(self, cr, uid, vals, context=None):
result = super(res_users, self).create(cr, uid, vals, context=context)
template_obj = self.pool.get('email.template')
group_model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'res.users')])[0]
body_html = """<html><head><title>Confirmation</title></head><body><h1>Welcome to board </h1><p>Hello ${object.name},</p></body></html>"""
template_data = {
'model_id': group_model_id,
'name': 'Template Name',
'subject' : 'Subject for your email',
'body_html': body_html,
'email_from' : 'From Email ID',
'email_to' : 'To Email ID',
}
template_id = template_obj.create(cr, uid, template_data, context=context)
template_obj.send_mail(cr, uid, template_id, result, force_send=True, context=context)
return result
Hope above code help for you.
Note: please manage proper indention in method.
Cheers,
Ankit H Gandhi.