Search code examples
python-3.xodooodoo-11

How can create and send a mail by python code without creating a mail template in xml in odoo


Is it possible to send an email without a mail template ? I need to send an email from python code without creating the mail template by xml.


Solution

  • Yes it is possible.You can pass the email values within the python code itself.

    values = {}
    email_to = 'receiver mail id'
    email_from = 'sender mail id'
    values['email_to'] = email_to
    values['email_from'] = email_from  // Not necessary
    values['subject'] = YOUR MAIL SUBJECT
    values['body'] = You Email Body
    self.env['mail.mail'].sudo().create(values).send() // Creating and sendimg the mail.