1.1 --- a/imiptools/mail.py Sun Jul 26 23:43:26 2015 +0200
1.2 +++ b/imiptools/mail.py Mon Jul 27 16:29:40 2015 +0200
1.3 @@ -40,27 +40,38 @@
1.4
1.5 "Sending of outgoing messages."
1.6
1.7 - def __init__(self, sender=None, subject=None, body_text=None, preamble_text=None):
1.8 + def __init__(self, lmtp_socket=None, sender=None, subject=None, body_text=None, preamble_text=None):
1.9 +
1.10 + """
1.11 + Deliver to a local mail system using LMTP if 'lmtp_socket' is provided.
1.12 + """
1.13 +
1.14 + self.lmtp_socket = lmtp_socket
1.15 self.sender = sender or MESSAGE_SENDER
1.16 self.subject = subject or MESSAGE_SUBJECT
1.17 self.body_text = body_text or MESSAGE_TEXT
1.18 self.preamble_text = preamble_text or PREAMBLE_TEXT
1.19
1.20 + def local_delivery(self):
1.21 +
1.22 + "Return whether local delivery is performed using this messenger."
1.23 +
1.24 + return self.lmtp_socket is not None
1.25 +
1.26 def sendmail(self, recipients, data, sender=None, outgoing_bcc=None, lmtp_socket=None):
1.27
1.28 """
1.29 Send a mail to the given 'recipients' consisting of the given 'data',
1.30 using the given 'sender' identity if indicated, indicating an
1.31 - 'outgoing_bcc' identity if indicated, delivering to a local mail system
1.32 - using LMTP if 'lmtp_socket' is provided.
1.33 + 'outgoing_bcc' identity if indicated.
1.34
1.35 The 'outgoing_bcc' argument is required when sending on behalf of a user
1.36 from the calendar@domain address, since this will not be detected as a
1.37 valid participant and handled using the outgoing transport.
1.38 """
1.39
1.40 - if lmtp_socket:
1.41 - smtp = LMTP(lmtp_socket)
1.42 + if self.lmtp_socket:
1.43 + smtp = LMTP(self.lmtp_socket)
1.44 else:
1.45 smtp = SMTP("localhost")
1.46