def __init__(self, email=None, server_url=None): if server_url is None: server_url = self.DEFAULT_SERVER_URL if email is None: email = "test-{uniq}@{hostname}" hostname = urlparse(server_url).hostname self.email = email.format(uniq=uniq(), hostname=hostname) self.server_url = server_url if self.email.endswith("@" + hostname): userid = self.email.rsplit("@", 1)[0] else: userid = self.email self.user_url = urljoin(self.server_url, "/mail/" + userid) self.messages = []