parameters: (self, message, mail_server_id=None, smtp_server=None, smtp_port=None,
                     smtp_user=None, smtp_password=None, smtp_encryption=None,
                     smtp_ssl_certificate=None, smtp_ssl_private_key=None,
                     smtp_debug=False, smtp_session=None)
return_statement: return message_id
docstring: Sends an email directly (no queuing).
  
          No retries are done, the caller should handle MailDeliveryException in order to ensure that
          the mail is never lost.
  
          If the mail_server_id is provided, sends using this mail server, ignoring other smtp_* arguments.
          If mail_server_id is None and smtp_server is None, use the default mail server (highest priority).
          If mail_server_id is None and smtp_server is not None, use the provided smtp_* arguments.
          If both mail_server_id and smtp_server are None, look for an 'smtp_server' value in server config,
          and fails if not found.
  
          :param message: the email.message.Message to send. The envelope sender will be extracted from the
                          ``Return-Path`` (if present), or will be set to the default bounce address.
                          The envelope recipients will be extracted from the combined list of ``To``,
                          ``CC`` and ``BCC`` headers.
          :param smtp_session: optional pre-established SMTP session. When provided,
                               overrides `mail_server_id` and all the `smtp_*` parameters.
                               Passing the matching `mail_server_id` may yield better debugging/log
                               messages. The caller is in charge of disconnecting the session.
          :param mail_server_id: optional id of ir.mail_server to use for sending. overrides other smtp_* arguments.
          :param smtp_server: optional hostname of SMTP server to use
          :param smtp_encryption: optional TLS mode, one of 'none', 'starttls' or 'ssl' (see ir.mail_server fields for explanation)
          :param smtp_port: optional SMTP port, if mail_server_id is not passed
          :param smtp_user: optional SMTP user, if mail_server_id is not passed
          :param smtp_password: optional SMTP password to use, if mail_server_id is not passed
          :param smtp_ssl_certificate: filename of the SSL certificate used for authentication
          :param smtp_ssl_private_key: filename of the SSL private key used for authentication
          :param smtp_debug: optional SMTP debug flag, if mail_server_id is not passed
          :return: the Message-ID of the message that was just sent, if successfully sent, otherwise raises
                   MailDeliveryException and logs root cause.
docstring_summary: Sends an email directly (no queuing).
docstring_tokens: Sends an email directly ( no queuing ) .
function: def send_email(self, message, mail_server_id=None, smtp_server=None, smtp_port=None,
                     smtp_user=None, smtp_password=None, smtp_encryption=None,
                     smtp_ssl_certificate=None, smtp_ssl_private_key=None,
                     smtp_debug=False, smtp_session=None):
          """Sends an email directly (no queuing).
  
          No retries are done, the caller should handle MailDeliveryException in order to ensure that
          the mail is never lost.
  
          If the mail_server_id is provided, sends using this mail server, ignoring other smtp_* arguments.
          If mail_server_id is None and smtp_server is None, use the default mail server (highest priority).
          If mail_server_id is None and smtp_server is not None, use the provided smtp_* arguments.
          If both mail_server_id and smtp_server are None, look for an 'smtp_server' value in server config,
          and fails if not found.
  
          :param message: the email.message.Message to send. The envelope sender will be extracted from the
                          ``Return-Path`` (if present), or will be set to the default bounce address.
                          The envelope recipients will be extracted from the combined list of ``To``,
                          ``CC`` and ``BCC`` headers.
          :param smtp_session: optional pre-established SMTP session. When provided,
                               overrides `mail_server_id` and all the `smtp_*` parameters.
                               Passing the matching `mail_server_id` may yield better debugging/log
                               messages. The caller is in charge of disconnecting the session.
          :param mail_server_id: optional id of ir.mail_server to use for sending. overrides other smtp_* arguments.
          :param smtp_server: optional hostname of SMTP server to use
          :param smtp_encryption: optional TLS mode, one of 'none', 'starttls' or 'ssl' (see ir.mail_server fields for explanation)
          :param smtp_port: optional SMTP port, if mail_server_id is not passed
          :param smtp_user: optional SMTP user, if mail_server_id is not passed
          :param smtp_password: optional SMTP password to use, if mail_server_id is not passed
          :param smtp_ssl_certificate: filename of the SSL certificate used for authentication
          :param smtp_ssl_private_key: filename of the SSL private key used for authentication
          :param smtp_debug: optional SMTP debug flag, if mail_server_id is not passed
          :return: the Message-ID of the message that was just sent, if successfully sent, otherwise raises
                   MailDeliveryException and logs root cause.
          """
          smtp = smtp_session
          if not smtp:
              smtp = self.connect(
                  smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption,
                  smtp_from=message['From'], ssl_certificate=smtp_ssl_certificate, ssl_private_key=smtp_ssl_private_key,
                  smtp_debug=smtp_debug, mail_server_id=mail_server_id,)
  
          smtp_from, smtp_to_list, message = self._prepare_email_message(message, smtp)
  
          # Do not actually send emails in testing mode!
          if self._is_test_mode():
              _test_logger.info("skip sending email in test mode")
              return message['Message-Id']
  
          try:
              message_id = message['Message-Id']
  
              if sys.version_info < (3, 7, 4):
                  # header folding code is buggy and adds redundant carriage
                  # returns, it got fixed in 3.7.4 thanks to bpo-34424
                  message_str = message.as_string()
                  message_str = re.sub('\r+(?!\n)', '', message_str)
  
                  mail_options = []
                  if any((not is_ascii(addr) for addr in smtp_to_list + [smtp_from])):
                      # non ascii email found, require SMTPUTF8 extension,
                      # the relay may reject it
                      mail_options.append("SMTPUTF8")
                  smtp.sendmail(smtp_from, smtp_to_list, message_str, mail_options=mail_options)
              else:
                  smtp.send_message(message, smtp_from, smtp_to_list)
  
              # do not quit() a pre-established smtp_session
              if not smtp_session:
                  smtp.quit()
          except smtplib.SMTPServerDisconnected:
              raise
          except Exception as e:
              params = (ustr(smtp_server), e.__class__.__name__, ustr(e))
              msg = _("Mail delivery failed via SMTP server '%s'.\n%s: %s", *params)
              _logger.info(msg)
              raise MailDeliveryException(_("Mail Delivery Failed"), msg)
          return message_id
function_tokens: def send_email ( self , message , mail_server_id = None , smtp_server = None , smtp_port = None , smtp_user = None , smtp_password = None , smtp_encryption = None , smtp_ssl_certificate = None , smtp_ssl_private_key = None , smtp_debug = False , smtp_session = None ) : smtp = smtp_session if not smtp : smtp = self . connect ( smtp_server , smtp_port , smtp_user , smtp_password , smtp_encryption , smtp_from = message [ 'From' ] , ssl_certificate = smtp_ssl_certificate , ssl_private_key = smtp_ssl_private_key , smtp_debug = smtp_debug , mail_server_id = mail_server_id , ) smtp_from , smtp_to_list , message = self . _prepare_email_message ( message , smtp ) # Do not actually send emails in testing mode! if self . _is_test_mode ( ) : _test_logger . info ( "skip sending email in test mode" ) return message [ 'Message-Id' ] try : message_id = message [ 'Message-Id' ] if sys . version_info < ( 3 , 7 , 4 ) : # header folding code is buggy and adds redundant carriage # returns, it got fixed in 3.7.4 thanks to bpo-34424 message_str = message . as_string ( ) message_str = re . sub ( '\r+(?!\n)' , '' , message_str ) mail_options = [ ] if any ( ( not is_ascii ( addr ) for addr in smtp_to_list + [ smtp_from ] ) ) : # non ascii email found, require SMTPUTF8 extension, # the relay may reject it mail_options . append ( "SMTPUTF8" ) smtp . sendmail ( smtp_from , smtp_to_list , message_str , mail_options = mail_options ) else : smtp . send_message ( message , smtp_from , smtp_to_list ) # do not quit() a pre-established smtp_session if not smtp_session : smtp . quit ( ) except smtplib . SMTPServerDisconnected : raise except Exception as e : params = ( ustr ( smtp_server ) , e . __class__ . __name__ , ustr ( e ) ) msg = _ ( "Mail delivery failed via SMTP server '%s'.\n%s: %s" , * params ) _logger . info ( msg ) raise MailDeliveryException ( _ ( "Mail Delivery Failed" ) , msg ) return message_id