# HG changeset patch # User Paul Boddie # Date 1418233328 -3600 # Node ID d52e08731368b4343e1bde5a8b597d5d2ec70b82 # Parent 391f000ce9e67e969ce8c9c7cb06fbb7eba0828a Changed manager-originating messages to use the agent identity, sending a Bcc to the outgoing agent instead of using the "sender Bcc" mechanism. This should work much better with any agent identity signing operations. diff -r 391f000ce9e6 -r d52e08731368 conf/postfix/main.cf.example --- a/conf/postfix/main.cf.example Wed Dec 10 17:35:00 2014 +0100 +++ b/conf/postfix/main.cf.example Wed Dec 10 18:42:08 2014 +0100 @@ -1,2 +1,3 @@ -virtual_alias_maps = $alias_maps, ldap:/etc/postfix/ldap/virtual_alias_maps_resources.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_people.cf +local_recipient_maps = ldap:/etc/postfix/ldap/local_recipient_maps.cf +virtual_alias_maps = $alias_maps, hash:/etc/postfix/virtual, ldap:/etc/postfix/ldap/virtual_alias_maps_resources.cf, ldap:/etc/postfix/ldap/virtual_alias_maps_people.cf sender_bcc_maps = ldap:/etc/postfix/ldap/virtual_alias_maps_people_outgoing.cf diff -r 391f000ce9e6 -r d52e08731368 conf/postfix/virtual --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/postfix/virtual Wed Dec 10 18:42:08 2014 +0100 @@ -0,0 +1,1 @@ +people-outgoing@example.com people-outgoing@example.com diff -r 391f000ce9e6 -r d52e08731368 imip_manager.py --- a/imip_manager.py Wed Dec 10 17:35:00 2014 +0100 +++ b/imip_manager.py Wed Dec 10 18:42:08 2014 +0100 @@ -84,14 +84,14 @@ def send_message(self, sender): """ - Create a full calendar object and send it to the organisers from the - given 'sender'. + Create a full calendar object and send it to the organisers, sending a + copy to the 'sender'. """ node = to_node(self.obj) part = to_part("REPLY", [node]) - message = self.messenger.make_message([part], self.organisers, sender=sender) - self.messenger.sendmail(self.organisers, message.as_string(), sender=sender) + message = self.messenger.make_message([part], self.organisers, outgoing_bcc=sender) + self.messenger.sendmail(self.organisers, message.as_string(), outgoing_bcc=sender) # Action methods. @@ -112,6 +112,8 @@ freebusy = self.store.get_freebusy(attendee) attendee_attr["PARTSTAT"] = accept and "ACCEPTED" or "DECLINED" + if self.messenger and self.messenger.sender != get_address(attendee): + attendee_attr["SENT-BY"] = get_uri(self.messenger.sender) self.details["ATTENDEE"] = [(attendee, attendee_attr)] self.send_message(get_address(attendee)) @@ -433,12 +435,6 @@ self.out.write(unicode(self.page).encode(self.encoding)) if __name__ == "__main__": - Manager( - Messenger( - "imip-agent@example.com", - "Calendar system message", - "This is a message from the calendar system." - ) - )() + Manager()() # vim: tabstop=4 expandtab shiftwidth=4 diff -r 391f000ce9e6 -r d52e08731368 imiptools/config.py --- a/imiptools/config.py Wed Dec 10 17:35:00 2014 +0100 +++ b/imiptools/config.py Wed Dec 10 18:42:08 2014 +0100 @@ -4,6 +4,10 @@ MESSAGE_SENDER = "calendar@example.com" +# The outgoing message handling prefix. + +OUTGOING_PREFIX = "people-outgoing" + # The location of the stored calendar information. STORE_DIR = "/var/lib/imip-agent/store" diff -r 391f000ce9e6 -r d52e08731368 imiptools/mail.py --- a/imiptools/mail.py Wed Dec 10 17:35:00 2014 +0100 +++ b/imiptools/mail.py Wed Dec 10 18:42:08 2014 +0100 @@ -1,6 +1,6 @@ #!/usr/bin/env python -from imiptools.config import MESSAGE_SENDER +from imiptools.config import MESSAGE_SENDER, OUTGOING_PREFIX from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText @@ -27,12 +27,13 @@ self.body_text = body_text or MESSAGE_TEXT self.preamble_text = preamble_text or PREAMBLE_TEXT - def sendmail(self, recipients, data, sender=None, lmtp_socket=None): + def sendmail(self, recipients, data, sender=None, outgoing_bcc=None, lmtp_socket=None): """ Send a mail to the given 'recipients' consisting of the given 'data', - using the given 'sender' identity if indicated, delivering to a local - mail system using LMTP if 'lmtp_socket' is provided. + using the given 'sender' identity if indicated, indicating an + 'outgoing_bcc' identity if indicated, delivering to a local mail system + using LMTP if 'lmtp_socket' is provided. """ if lmtp_socket: @@ -40,14 +41,18 @@ else: smtp = SMTP("localhost") + if outgoing_bcc: + recipients = list(recipients) + ["%s+%s" % (OUTGOING_PREFIX, outgoing_bcc)] + smtp.sendmail(sender or self.sender, recipients, data) smtp.quit() - def make_message(self, parts, recipients, sender=None): + def make_message(self, parts, recipients, sender=None, outgoing_bcc=None): """ Make a message from the given 'parts' for the given 'recipients', using - the given 'sender' identity if indicated. + the given 'sender' identity if indicated, indicating an 'outgoing_bcc' + identity if indicated. """ message = MIMEMultipart("mixed", _subparts=parts) @@ -58,6 +63,8 @@ message["From"] = sender or self.sender for recipient in recipients: message["To"] = recipient + if outgoing_bcc: + message["Bcc"] = "%s+%s" % (OUTGOING_PREFIX, outgoing_bcc) message["Subject"] = self.subject return message