Skip to content

Commit

Permalink
[FIX] backport _smtp_login as well
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Apr 6, 2023
1 parent 916a94f commit a9c27a2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion odoo/addons/base/ir/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def connect(self, host=None, port=None, user=None, password=None, encryption=Non
elif not host:
mail_server = self.sudo().search([], order='sequence', limit=1)

if not mail_server:
mail_server = self.env['ir.mail_server']

if mail_server:
smtp_server = mail_server.smtp_host
smtp_port = mail_server.smtp_port
Expand Down Expand Up @@ -241,9 +244,19 @@ def connect(self, host=None, port=None, user=None, password=None, encryption=Non
# See also bug #597143 and python issue #5285
smtp_user = pycompat.to_native(ustr(smtp_user))
smtp_password = pycompat.to_native(ustr(smtp_password))
connection.login(smtp_user, smtp_password)
mail_server._smtp_login(connection, smtp_user, smtp_password)
return connection

def _smtp_login(self, connection, smtp_user, smtp_password):
"""Authenticate the SMTP connection.
Can be overridden in other module for different authentication methods.Can be
called on the model itself or on a singleton.
:param connection: The SMTP connection to authenticate
:param smtp_user: The user to used for the authentication
:param smtp_password: The password to used for the authentication
"""
connection.login(smtp_user, smtp_password)

def build_email(self, 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'):
Expand Down

0 comments on commit a9c27a2

Please sign in to comment.