changeset f9f1ecc399f7 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=f9f1ecc399f7
description:
        Add strict parameter to sendmail_transactional

        and complete the documentation.

        issue10681
        review353811002
diffstat:

 doc/ref/sendmail.rst |  7 +++++--
 trytond/sendmail.py  |  5 +++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r 9479f2f53ca1 -r f9f1ecc399f7 doc/ref/sendmail.rst
--- a/doc/ref/sendmail.rst      Mon Aug 30 00:26:41 2021 +0200
+++ b/doc/ref/sendmail.rst      Thu Sep 02 23:14:56 2021 +0200
@@ -5,7 +5,7 @@
 Sendmail
 ========
 
-.. method:: sendmail_transactional(from_addr, to_addrs, msg[, transaction[, 
datamanager]])
+.. method:: sendmail_transactional(from_addr, to_addrs, msg[, transaction[, 
datamanager[, strict]]])
 
 Send email message only if the current transaction is successfully committed.
 The required arguments are an `RFC 822`_ from-address string, a list of `RFC
@@ -14,16 +14,19 @@
 The caller may pass a :class:`Transaction` instance to join otherwise the
 current one will be joined. A specific data manager can be specified otherwise
 the default :class:`SMTPDataManager` will be used for sending email.
+The strict value is passed to instantiate the default :class:`SMTPDataManager`.
 
 .. warning::
 
     An SMTP failure will be only logged without raising any exception.
 
-.. method:: sendmail(from_addr, to_addrs, msg[, server])
+.. method:: sendmail(from_addr, to_addrs, msg[, server[, strict]])
 
 Send email message like :meth:`sendmail_transactional` but directly without
 caring about the transaction.
 The caller may pass a server instance from `smtplib`_.
+If strict is ``True``, an exception is raised if it is not possible to connect
+to the server.
 
 .. method:: get_smtp_server([uri[, strict]])
 
diff -r 9479f2f53ca1 -r f9f1ecc399f7 trytond/sendmail.py
--- a/trytond/sendmail.py       Mon Aug 30 00:26:41 2021 +0200
+++ b/trytond/sendmail.py       Thu Sep 02 23:14:56 2021 +0200
@@ -15,12 +15,13 @@
 
 
 def sendmail_transactional(
-        from_addr, to_addrs, msg, transaction=None, datamanager=None):
+        from_addr, to_addrs, msg, transaction=None, datamanager=None,
+        strict=False):
     if transaction is None:
         transaction = Transaction()
     assert isinstance(transaction, Transaction), transaction
     if datamanager is None:
-        datamanager = SMTPDataManager()
+        datamanager = SMTPDataManager(strict=strict)
     datamanager = transaction.join(datamanager)
     datamanager.put(from_addr, to_addrs, msg)
 

Reply via email to