|
|
return self._full_path | return self._full_path |
| |
def getListAddress(self, extra=None): | def getListAddress(self, extra=None): |
|
posting_addr = self.internal_name() |
|
try: |
|
posting_addr = self.real_name |
|
except: |
|
pass |
if extra is None: | if extra is None: |
return '%s@%s' % (self.internal_name(), self.host_name) |
return '%s@%s' % (posting_addr, self.host_name) |
return '%s-%s@%s' % (self.internal_name(), extra, self.host_name) |
return '%s-%s@%s' % (posting_addr, extra, self.host_name) |
| |
# For backwards compatibility | # For backwards compatibility |
def GetBouncesEmail(self): | def GetBouncesEmail(self): |
|
|
def Create(self, name, admin, crypted_password, | def Create(self, name, admin, crypted_password, |
langs=None, emailhost=None): | langs=None, emailhost=None): |
assert name == name.lower(), 'List name must be all lower case.' | assert name == name.lower(), 'List name must be all lower case.' |
if Utils.list_exists(name): |
|
raise Errors.MMListAlreadyExistsError, name |
|
# Validate what will be the list's posting address. If that's | # Validate what will be the list's posting address. If that's |
# invalid, we don't want to create the mailing list. The hostname | # invalid, we don't want to create the mailing list. The hostname |
# part doesn't really matter, since that better already be valid. | # part doesn't really matter, since that better already be valid. |
|
|
# the admin's email address, so transform the exception. | # the admin's email address, so transform the exception. |
if emailhost is None: | if emailhost is None: |
emailhost = mm_cfg.DEFAULT_EMAIL_HOST | emailhost = mm_cfg.DEFAULT_EMAIL_HOST |
postingaddr = '%s@%s' % (name, emailhost) |
firstname = name |
|
if '@' in name: |
|
firstname, emailhost = name.split('@', 1) |
|
# Keep posting address sane. |
|
postingaddr = '%s@%s' % (firstname, emailhost) |
|
name = '%s-%s' % (firstname, emailhost) |
try: | try: |
Utils.ValidateEmail(postingaddr) | Utils.ValidateEmail(postingaddr) |
except Errors.MMBadEmailError: | except Errors.MMBadEmailError: |
raise Errors.BadListNameError, postingaddr | raise Errors.BadListNameError, postingaddr |
|
# Refuse to create lists that already exists |
|
if Utils.list_exists(name): |
|
raise Errors.MMListAlreadyExistsError, name |
# Validate the admin's email address | # Validate the admin's email address |
Utils.ValidateEmail(admin) | Utils.ValidateEmail(admin) |
self._internal_name = name | self._internal_name = name |
|
|
# Don't use Lock() since that tries to load the non-existant config.pck | # Don't use Lock() since that tries to load the non-existant config.pck |
self.__lock.lock() | self.__lock.lock() |
self.InitVars(name, admin, crypted_password) | self.InitVars(name, admin, crypted_password) |
|
# This is for getListAddress |
|
self.list_address = postingaddr |
|
self.real_name = firstname |
|
self.subject_prefix = mm_cfg.DEFAULT_SUBJECT_PREFIX % self.__dict__ |
self.CheckValues() | self.CheckValues() |
if langs is None: | if langs is None: |
self.available_languages = [self.preferred_language] | self.available_languages = [self.preferred_language] |
|
|
addresses in the recipient headers. | addresses in the recipient headers. |
""" | """ |
# This is the list's full address. | # This is the list's full address. |
listfullname = '%s@%s' % (self.internal_name(), self.host_name) |
listfullname = self.getListAddress() |
recips = [] | recips = [] |
# Check all recipient addresses against the list's explicit addresses, | # Check all recipient addresses against the list's explicit addresses, |
# specifically To: Cc: and Resent-to: | # specifically To: Cc: and Resent-to: |