def test_add_received_header(self): env = Envelope('*****@*****.**', ['*****@*****.**']) env.parse('') env.timestamp = 1234567890 env.client['name'] = 'mail.example.com' env.client['ip'] = '1.2.3.4' env.client['protocol'] = 'ESMTPS' env.receiver = 'test.com' arh = AddReceivedHeader() arh.apply(env) self.assertRegexpMatches(env.headers['Received'], r'from mail\.example\.com \(unknown \[1.2.3.4\]\) by test.com ' r'\(slimta [^\)]+\) with ESMTPS for <*****@*****.**>; ')
def test_add_received_header(self): env = Envelope('*****@*****.**', ['*****@*****.**']) env.parse(b'From: [email protected]\r\n') env.timestamp = 1234567890 env.client['name'] = 'mail.example.com' env.client['ip'] = '1.2.3.4' env.client['protocol'] = 'ESMTPS' env.receiver = 'test.com' arh = AddReceivedHeader() arh.apply(env) self.assertRegexpMatches( env.headers['Received'], r'from mail\.example\.com \(unknown \[1.2.3.4\]\) by test.com ' r'\(slimta [^\)]+\) with ESMTPS for <*****@*****.**>; ')
def _start_outbound_queue(args, relay, inbound_queue): from slimta.queue.dict import DictStorage from slimta.queue import Queue from slimta.policy.headers import AddDateHeader, \ AddMessageIdHeader, AddReceivedHeader from slimta.policy.split import RecipientDomainSplit envelope_db = {} meta_db = {} storage = DictStorage(envelope_db, meta_db) queue = Queue(storage, relay, bounce_queue=inbound_queue) queue.start() queue.add_policy(AddDateHeader()) queue.add_policy(AddMessageIdHeader()) queue.add_policy(AddReceivedHeader()) queue.add_policy(RecipientDomainSplit()) return queue
def _start_inbound_queue(args, relay): from slimta.queue.dict import DictStorage from slimta.queue import Queue from slimta.policy.headers import AddDateHeader, \ AddMessageIdHeader, AddReceivedHeader from slimta.policy.spamassassin import SpamAssassin envelope_db = {} meta_db = {} storage = DictStorage(envelope_db, meta_db) queue = Queue(storage, relay) queue.start() queue.add_policy(AddDateHeader()) queue.add_policy(AddMessageIdHeader()) queue.add_policy(AddReceivedHeader()) if args.spamassassin: queue.add_policy(SpamAssassin()) return queue
def test_add_received_header_prepended(self): env = Envelope('*****@*****.**', ['*****@*****.**']) env.parse(b'From: [email protected]\r\n') AddReceivedHeader().apply(env) self.assertEqual(['Received', 'From'], env.headers.keys())