MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / smtpServerChannel

Class smtpServerChannel

src/class_smtpServer.py:26–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24LISTENPORT = 8425
25
26class smtpServerChannel(smtpd.SMTPChannel):
27 def smtp_EHLO(self, arg):
28 if not arg:
29 self.push('501 Syntax: HELO hostname')
30 return
31 self.push('250-PyBitmessage %s' % softwareVersion)
32 self.push('250 AUTH PLAIN')
33
34 def smtp_AUTH(self, arg):
35 if not arg or arg[0:5] not in ["PLAIN"]:
36 self.push('501 Syntax: AUTH PLAIN')
37 return
38 authstring = arg[6:]
39 try:
40 decoded = base64.b64decode(authstring)
41 correctauth = "\x00" + BMConfigParser().safeGet("bitmessagesettings", "smtpdusername", "") + \
42 "\x00" + BMConfigParser().safeGet("bitmessagesettings", "smtpdpassword", "")
43 logger.debug("authstring: %s / %s", correctauth, decoded)
44 if correctauth == decoded:
45 self.auth = True
46 self.push('235 2.7.0 Authentication successful')
47 else:
48 raise Exception("Auth fail")
49 except:
50 self.push('501 Authentication fail')
51
52 def smtp_DATA(self, arg):
53 if not hasattr(self, "auth") or not self.auth:
54 self.push ("530 Authentication required")
55 return
56 smtpd.SMTPChannel.smtp_DATA(self, arg)
57
58
59class smtpServerPyBitmessage(smtpd.SMTPServer):

Callers 1

handle_acceptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected