A few extra fixes as pointed out by AyrA

This commit is contained in:
Chuck 2013-07-05 18:22:52 +07:00
parent 0cf256a8c2
commit d035f3d0e4

View File

@ -107,7 +107,7 @@ class bitmessageSMTPChannel(asynchat.async_chat):
self.__rcpttos, self.__rcpttos,
self.__data) self.__data)
except Exception, e: except Exception, e:
status = '451 Requested action aborted: {}'.format(str(e)) status = '554 Requested transaction failed: {}'.format(str(e))
self.__rcpttos = [] self.__rcpttos = []
self.__mailfrom = None self.__mailfrom = None
@ -158,7 +158,7 @@ class bitmessageSMTPChannel(asynchat.async_chat):
return return
if encoding != 'PLAIN': if encoding != 'PLAIN':
self.invalid_command('501 method not understood') self.invalid_command('502 method not understood')
return return
try: try:
@ -167,7 +167,7 @@ class bitmessageSMTPChannel(asynchat.async_chat):
z = 'error' z = 'error'
if z != '': if z != '':
self.invalid_command('501 method not understood') self.invalid_command('501 authorization not understood')
return return
if '@' not in username: if '@' not in username:
@ -253,7 +253,7 @@ class bitmessageSMTPChannel(asynchat.async_chat):
return return
if address != self.fullUsername: if address != self.fullUsername:
self.invalid_command('530 Access denied: address domain must match Bitmessage identity') self.invalid_command('530 Access denied: address must be the same as the authorized account')
return return
self.__mailfrom = address self.__mailfrom = address
@ -271,9 +271,13 @@ class bitmessageSMTPChannel(asynchat.async_chat):
return return
address = self.__getaddr('TO:', arg) if arg else None address = self.__getaddr('TO:', arg) if arg else None
if not address: if not address:
self.invalid_command('501 Syntax: RCPT TO: <address>') self.invalid_command('501 Syntax: RCPT TO: <user@address>')
return return
try:
capitalization, address = address.split('@', 1) capitalization, address = address.split('@', 1)
except ValueError:
self.invalid_command('501 Syntax: RCPT TO: <user@address>')
return
realAddress = applyBase58Capitalization(address, int(capitalization)) realAddress = applyBase58Capitalization(address, int(capitalization))
self.__rcpttos.append('{}@{}'.format(getBase58Capitaliation(realAddress), realAddress)) self.__rcpttos.append('{}@{}'.format(getBase58Capitaliation(realAddress), realAddress))
print >> smtpd.DEBUGSTREAM, 'recips:', self.__rcpttos print >> smtpd.DEBUGSTREAM, 'recips:', self.__rcpttos
@ -336,7 +340,7 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
#print(type(address)) #print(type(address))
message = parser.Parser().parsestr(data) message = parser.Parser().parsestr(data)
message['Bitmessage-Version'] = shared.softwareVersion message['X-Bitmessage-Version'] = shared.softwareVersion
print(message) print(message)
fp = StringIO() fp = StringIO()