Beispiel #1
0
def create_temp_email(session_id, real_email):
    """
    Create a new disposable email address.

    For this, we need to provide the session ID.
    The real email address must be given too where
    emails will be redirected to.
    """
    payload = {
        "data": {
            "id": -1,
            "uid": None,
            "ctime": 0,
            "ctime_text": "",
            "disposable_name": userpass.get_urandom_password(8),
            "disposable_domain": "trashmail.net",
            "destination": real_email,
            "forwards":
            10,  # that's the maximum number of forwards for the free service
            "expire": 7,  # max. value: 31 (one month)
            "website": "",
            "cs": 0,
            "notify": True,
            "desc": ""
        }
    }
    cookie = {'trashmail_session': session_id}
    headers = {'content-type': 'text/plain'}

    r = requests.post('https://ssl.trashmail.net/?api=1&cmd=update_dea',
                      cookies=cookie,
                      data=json.dumps(payload),
                      headers=headers)
    if DEBUG:
        print r.text
    data = r.json()['data'][0]
    temp_email = "{0}@{1}".format(data['disposable_name'],
                                  data['disposable_domain'])

    return temp_email
Beispiel #2
0
def create_temp_email(session_id, real_email):
    """
    Create a new disposable email address.

    For this, we need to provide the session ID.
    The real email address must be given too where
    emails will be redirected to.
    """
    payload = {
        "data": {
            "id": -1,
            "uid": None,
            "ctime": 0,
            "ctime_text": "",
            "disposable_name": userpass.get_urandom_password(8),
            "disposable_domain": "trashmail.net",
            "destination": real_email,
            "forwards": 10,     # that's the maximum number of forwards for the free service
            "expire": 7,        # max. value: 31 (one month)
            "website": "",
            "cs": 0,
            "notify": True,
            "desc": ""
        }
    }
    cookie = {'trashmail_session': session_id}
    headers = {'content-type': 'text/plain'}

    r = requests.post('https://ssl.trashmail.net/?api=1&cmd=update_dea',
        cookies=cookie, data=json.dumps(payload), headers=headers
    )
    if DEBUG:
        print r.text
    data = r.json()['data'][0]
    temp_email = "{0}@{1}".format(data['disposable_name'], data['disposable_domain'])

    return temp_email
def test_get_urandom_password():
    passwd = userpass.get_urandom_password(min=5, max=10)
    assert passwd.isalnum()
    assert 5 <= len(passwd) <= 10
Beispiel #4
0
def test_get_urandom_password():
    passwd = userpass.get_urandom_password(min=5, max=10)
    assert passwd.isalnum()
    assert 5 <= len(passwd) <= 10