VirtualMailManager/VirtualMailManager.py
changeset 52 c152d7714802
parent 51 f5ca21303871
child 53 5b50eb306d37
equal deleted inserted replaced
51:f5ca21303871 52:c152d7714802
   190             raise VMMException(_(u"Missing '@' sign in e-mail address »%s«.") %
   190             raise VMMException(_(u"Missing '@' sign in e-mail address »%s«.") %
   191                 address, ERR.INVALID_ADDRESS)
   191                 address, ERR.INVALID_ADDRESS)
   192         except AttributeError:
   192         except AttributeError:
   193             raise VMMException(_(u"»%s« looks not like an e-mail address.") %
   193             raise VMMException(_(u"»%s« looks not like an e-mail address.") %
   194                 address, ERR.INVALID_ADDRESS)
   194                 address, ERR.INVALID_ADDRESS)
   195         domain = VirtualMailManager.chkDomainname(domain)
   195         if len(domain) > 0:
       
   196             domain = VirtualMailManager.chkDomainname(domain)
       
   197         else:
       
   198             raise VMMException(_(u"Missing domain name after »%s@«.") %
       
   199                     localpart, ERR.DOMAIN_NO_NAME)
   196         localpart = VirtualMailManager.chkLocalpart(localpart)
   200         localpart = VirtualMailManager.chkLocalpart(localpart)
   197         return '%s@%s' % (localpart, domain)
   201         return '%s@%s' % (localpart, domain)
   198     chkEmailAddress = staticmethod(chkEmailAddress)
   202     chkEmailAddress = staticmethod(chkEmailAddress)
   199 
   203 
   200     def __getAccount(self, address, password=None):
   204     def __getAccount(self, address, password=None):
   217                 clear0 = ''
   221                 clear0 = ''
   218                 sys.stderr.write('%s\n' % _('Sorry, passwords do not match'))
   222                 sys.stderr.write('%s\n' % _('Sorry, passwords do not match'))
   219         return clear0
   223         return clear0
   220 
   224 
   221     def __getAlias(self, address, destination=None):
   225     def __getAlias(self, address, destination=None):
   222         address = VirtualMailManager.chkEmailAddress(address)
       
   223         if not destination is None:
       
   224             if destination.count('@'):
       
   225                 destination = VirtualMailManager.chkEmailAddress(destination)
       
   226             else:
       
   227                 destination = VirtualMailManager.chkLocalpart(destination)
       
   228         self.__dbConnect()
   226         self.__dbConnect()
   229         return Alias(self.__dbh, address, destination)
   227         return Alias(self.__dbh, address, destination)
   230 
   228 
   231     def __getDomain(self, domainname, transport=None):
   229     def __getDomain(self, domainname, transport=None):
   232         if transport is None:
   230         if transport is None: