Better debugging mail server

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
"""
Like the built-in debugging server, but unwarps long lines for easier
copy/paste of URLs.
"""
from __future__ import print_function
from smtpd import SMTPServer
import os

class DebuggingServer(SMTPServer):
    def process_message(self, peer, mailfrom, rcpttos, data):
        inheaders = 1
        lines = data.split('\n')
        print('---------- MESSAGE FOLLOWS ----------')
        for line in lines:
            # headers first
            if inheaders and not line:
                print('X-Peer:', peer[0])
                inheaders = 0
            if line.endswith('='):
                print(line[:-1], end='')
            else:
                print(line)
        print('------------ END MESSAGE ------------')

if __name__ == "__main__":
    os.system("python -m smtpd -n -c better.DebuggingServer localhost:1025")

More like this

  1. Email queue in DB by fish2000 4 years ago
  2. SMTP sink server by twinsant 7 years, 1 month ago
  3. SMTP sink server: prettier output by huwshimi 3 years, 11 months ago
  4. ReportBug() with tons of debug in mail by sleepycal 3 years, 6 months ago
  5. Effective content caching for mass-load site using redirect feature by nnseva 2 years, 9 months ago

Comments

(Forgotten your password?)