1.1 --- a/imiptools/mail.py Sat Oct 14 16:42:55 2017 +0200
1.2 +++ b/imiptools/mail.py Sat Oct 14 19:10:09 2017 +0200
1.3 @@ -44,11 +44,19 @@
1.4
1.5 "Sending of outgoing messages."
1.6
1.7 - def __init__(self, lmtp_socket=None, local_smtp=False, sender=None, subject=None, preamble_text=None):
1.8 + def __init__(self, lmtp_socket=None, local_smtp=False, sender=None,
1.9 + subject=None, preamble_text=None, suppress_bcc=False):
1.10
1.11 """
1.12 Deliver to a local mail system using LMTP if 'lmtp_socket' is provided
1.13 or if 'local_smtp' is given as a true value.
1.14 +
1.15 + Use 'sender' as the sender identity (or the configured default if not
1.16 + specified). Use any explicitly specified 'subject' and 'preamble_text'
1.17 + in sent messages.
1.18 +
1.19 + Where 'suppress_bcc' is set to a true value, messages will not be sent
1.20 + to an outgoing destination for the sender even if this is requested.
1.21 """
1.22
1.23 self.lmtp_socket = lmtp_socket
1.24 @@ -56,6 +64,7 @@
1.25 self.sender = sender or MESSAGE_SENDER
1.26 self.subject = subject
1.27 self.preamble_text = preamble_text
1.28 + self.suppress_bcc = suppress_bcc
1.29
1.30 # The translation method is set by the client once locale information is
1.31 # known.
1.32 @@ -85,7 +94,7 @@
1.33 else:
1.34 smtp = SMTP("localhost")
1.35
1.36 - if outgoing_bcc:
1.37 + if outgoing_bcc and not self.suppress_bcc:
1.38 recipients = list(recipients) + ["%s+%s" % (OUTGOING_PREFIX, outgoing_bcc)]
1.39 elif self.local_smtp:
1.40 recipients = [self.make_local(recipient) for recipient in recipients]
1.41 @@ -121,8 +130,10 @@
1.42 message["From"] = sender or self.sender
1.43 for recipient in recipients:
1.44 message["To"] = recipient
1.45 - if outgoing_bcc:
1.46 +
1.47 + if outgoing_bcc and not self.suppress_bcc:
1.48 message["Bcc"] = "%s+%s" % (OUTGOING_PREFIX, outgoing_bcc)
1.49 +
1.50 message["Subject"] = self.subject or \
1.51 self.gettext and self.gettext(MESSAGE_SUBJECT) or MESSAGE_SUBJECT
1.52