diff --git a/roundup/mailgw.py b/roundup/mailgw.py
index c7a8b68f75913961e1619c1391b437b4faa38492..66102ebee56a4ffbaed38b8f50e99b20a0857d19 100644 (file)
--- a/roundup/mailgw.py
+++ b/roundup/mailgw.py
an exception, the original message is bounced back to the sender with the
explanatory message given in the exception.
-$Id: mailgw.py,v 1.112 2003-03-24 02:51:21 richard Exp $
+$Id: mailgw.py,v 1.116 2003-04-17 06:51:44 richard Exp $
'''
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
import time, random, sys
import traceback, MimeWriter, rfc822
-import hyperdb, date, password
-import rfc2822
+from roundup import hyperdb, date, password, rfc2822
SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '')
def do_apop(self, server, user='', password=''):
''' Do authentication POP
'''
- self.do_pop(server, user, password, apop=1):
+ self.do_pop(server, user, password, apop=1)
def do_pop(self, server, user='', password='', apop=0):
'''Read a series of messages from the specified POP server.
# parse the body of the message, stripping out bits as appropriate
summary, content = parseContent(content, keep_citations,
keep_body)
+ content = content.strip()
#
# handle the attachments
# couldn't match address or username, so create a new user
if create:
- return db.user.create(username=address, address=address,
+ # generate a username
+ if '@' in address:
+ username = address.split('@')[0]
+ else:
+ username = address
+ trying = username
+ n = 0
+ while 1:
+ try:
+ # does this username exist already?
+ db.user.lookup(trying)
+ except KeyError:
+ break
+ n += 1
+ trying = username + str(n)
+
+ # create!
+ return db.user.create(username=trying, address=address,
realname=realname, roles=db.config.NEW_EMAIL_USER_ROLES,
+ password=password.Password(password.generatePassword()),
**user_props)
else:
return 0