def __init__(self, Peer, From=None, To=None, Data=None): """ Peer is the remote peer making the connection (sometimes the queue name). From and To are what you think they are. Data is the raw full email as received by the server. Peer can also be an instance of IncomingMessage and will be upgraded into a MailRequest. NOTE: It does not handle multiple From headers, if that's even possible. It will parse the From into a list and take the first one. """ if isinstance(Peer, IncomingMessage): old_msg = Peer self.Peer = old_msg.Peer self.From = old_msg.From self.To = old_msg.To self.Data = old_msg.Data else: super(MailRequest, self).__init__(Peer, From, To, Data) self.Email = encoding.from_string(self.Data) if 'from' not in self.Email: self.Email['from'] = self.From if 'to' not in self.Email: # do NOT use ROUTABLE_TO here self.Email['to'] = self.To self.From = self.From or self.Email['from'] self.To = self.To or self.Email[ROUTABLE_TO_HEADER] self.bounce = None
def __init__(self, Peer, From, To, Data): """ Peer is the remote peer making the connection (sometimes the queue name). From and To are what you think they are. Data is the raw full email as received by the server. NOTE: It does not handle multiple From headers, if that's even possible. It will parse the From into a list and take the first one. """ self.original = Data self.base = encoding.from_string(Data) self.Peer = Peer self.From = From or self.base['from'] self.To = To or self.base[ROUTABLE_TO_HEADER] if 'from' not in self.base: self.base['from'] = self.From if 'to' not in self.base: # do NOT use ROUTABLE_TO here self.base['to'] = self.To self.route_to = _decode_header_randomness(self.To) self.route_from = _decode_header_randomness(self.From) if self.route_from: self.route_from = self.route_from.pop() else: self.route_from = None self.bounce = None
def __init__(self, Peer, From, To, Data): """ Peer is the remote peer making the connection (sometimes the queue name). From and To are what you think they are. Data is the raw full email as received by the server. NOTE: It does not handle multiple From headers, if that's even possible. It will parse the From into a list and take the first one. """ self.Peer = Peer self.Data = Data try: self.From = _decode_header_randomness(From).pop() except KeyError: self.From = None try: self.To = _decode_header_randomness(To).pop() except KeyError: self.To = None self.base = encoding.from_string(self.Data) if 'from' not in self.base: self.base['from'] = self.From if 'to' not in self.base: # do NOT use ROUTABLE_TO here self.base['to'] = self.To self.From = self.From or self.base['from'] self.To = self.To or self.base[ROUTABLE_TO_HEADER] self.bounce = None
def __init__(self, Peer, From, To, Data): """ Peer is the remote peer making the connection (sometimes the queue name). From and To are what you think they are. Data is the raw full email as received by the server. NOTE: It does not handle multiple From headers, if that's even possible. It will parse the From into a list and take the first one. """ self.Peer = Peer self.Data = Data try: self.From = _decode_header_randomness(From).pop() except KeyError: self.From = None try: self.To = _decode_header_randomness(To).pop() except KeyError: self.To = None self.Email = encoding.from_string(self.Data) if 'from' not in self.Email: self.Email['from'] = self.From if 'to' not in self.Email: # do NOT use ROUTABLE_TO here self.Email['to'] = self.To self.From = self.From or self.Email['from'] self.To = self.To or self.Email[ROUTABLE_TO_HEADER] self.bounce = None