def craft_response(message, list_name, list_addr): response = MailResponse(To=list_addr, From=message['from'], Subject=message['subject']) msg_id = message['message-id'] response.update({ "Sender": list_addr, "Reply-To": list_addr, "List-Id": list_addr, "List-Unsubscribe": "<mailto:%[email protected]>" % list_name, "List-Archive": "<http://librelist.com/archives/%s/>" % list_name, "List-Post": "<mailto:%s>" % list_addr, "List-Help": "<http://librelist.com/help.html>", "List-Subscribe": "<mailto:%[email protected]>" % list_name, "Return-Path": list_addr, "Precedence": 'list', }) if 'date' in message: response['Date'] = message['date'] if 'references' in message: response['References'] = message['References'] elif msg_id: response['References'] = msg_id if msg_id: response['message-id'] = msg_id if 'in-reply-to' not in message: response["In-Reply-To"] = message['Message-Id'] if message.all_parts(): response.attach_all_parts(message) else: response.Body = message.body() return response
def craft_response(message, list_name, list_addr): response = MailResponse(To=list_addr, From=message['from'], Subject=message['subject']) msg_id = message['message-id'] response.update({ "Sender": list_addr, "Reply-To": list_addr, "List-Id": list_addr, "List-Unsubscribe": "<mailto:%[email protected]>" % list_name, "List-Archive": "<http://postosaurus.com/archives/%s/>" % list_name, "List-Post": "<mailto:%s>" % list_addr, "List-Help": "<http://postosaurus.com/help.html>", "List-Subscribe": "<mailto:%[email protected]>" % list_name, "Return-Path": list_addr, "Precedence": 'list', }) if 'date' in message: response['Date'] = message['date'] if 'references' in message: response['References'] = message['References'] elif msg_id: response['References'] = msg_id if msg_id: response['message-id'] = msg_id if 'in-reply-to' not in message: response["In-Reply-To"] = message['Message-Id'] if message.all_parts(): for part in message.all_parts(): if part: response.attach_part(part) response.base.content_encoding = message.base.content_encoding.copy() else: response.Body = message.body() return response