LQ自助邮箱提取

邮箱库存

Hotmail:

Outlook:

(24H不间断注册中,库存少说明遇到风控,可以过几个小时再来看看)

充值余额 LQ小店 点击此处

余额:

提取邮箱

邮箱列表

获取到的邮箱格式: Email : Password : RefreshToken : Client_ID ( 如何使用 IMAP与POP3 请看下方代码示例 )

Graph API 代码示例

点击展开/折叠代码

import requests

def get_access_token(refresh_token: str, client_id: str) -> str:
    res = requests.post(
        "https://login.microsoftonline.com/common/oauth2/v2.0/token",
        data={
            "client_id": client_id,
            "grant_type": "refresh_token",
            "refresh_token": refresh_token,
            "scope": "https://graph.microsoft.com/.default"
        }
    )
    return res.json()["access_token"]

def print_inbox(access_token: str) -> None:
    res = requests.get(
        "https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages",
        headers={"Authorization": f"Bearer {access_token}"},
    )
    res.raise_for_status()
    for m in res.json().get("value", []):
        print(f"主题: {m.get('subject')}")
        print(f"发件人: {m.get('from', {}).get('emailAddress', {}).get('address')}")
        print(f"内容预览: {m.get('bodyPreview')}")
        print(f"{'-'*50}")

client_id = "YOUR_CLIENT_ID"
refresh_token = "YOUR_REFRESH_TOKEN"
access_token = get_access_token(refresh_token, client_id)
print_inbox(access_token)

IMAP 代码示例

点击展开/折叠代码

import base64
import imaplib
import email
import requests

def get_access_token(client_id: str, refresh_token: str) -> str:
    data = {
        "client_id": client_id,
        "grant_type": "refresh_token",
        "refresh_token": refresh_token
    }
    res = requests.post("https://login.live.com/oauth20_token.srf", data=data)
    return res.json()["access_token"]

def generate_auth_string(user: str, token: str) -> str:
    return f"user={user}\1auth=Bearer {token}\1\1"

def connect_imap(email_addr: str, access_token: str) -> None:
    mail = imaplib.IMAP4_SSL("outlook.office365.com")
    mail.authenticate("XOAUTH2", lambda x: generate_auth_string(email_addr, access_token))
    mail.select("INBOX")
    status, messages = mail.search(None, "ALL")
    for num in messages[0].split():
        typ, data = mail.fetch(num, "(RFC822)")
        msg = email.message_from_bytes(data[0][1])
        subject = msg.get("subject")
        from_email = msg.get("from")
        body_preview = ""
        if msg.is_multipart():
            for part in msg.walk():
                if part.get_content_type() == "text/plain":
                    body_preview = part.get_payload(decode=True).decode("utf-8")[:80]
                    break
        else:
            body_preview = msg.get_payload(decode=True).decode("utf-8")[:80]
        print(f"主题: {subject}")
        print(f"发件人: {from_email}")
        print(f"内容预览: {body_preview}")
        print(f"{'-'*50}")
    mail.logout()

client_id = "YOUR_CLIENT_ID"
email_addr = "YOUR_EMAIL"
refresh_token = "YOUR_REFRESH_TOKEN"
access_token = get_access_token(client_id, refresh_token)
connect_imap(email_addr, access_token)

POP3 代码示例

点击展开/折叠代码

import base64
import poplib
import email
import requests

def get_access_token(client_id: str, refresh_token: str) -> str:
    data = {
        "client_id": client_id,
        "grant_type": "refresh_token",
        "refresh_token": refresh_token
    }
    res = requests.post("https://login.live.com/oauth20_token.srf", data=data)
    return res.json()["access_token"]

def generate_auth_string(user: str, token: str) -> str:
    return f"user={user}\1auth=Bearer {token}\1\1"

def connect_pop3(email_addr: str, access_token: str) -> None:
    server = poplib.POP3_SSL("outlook.office365.com", 995)
    auth_string = generate_auth_string(email_addr, access_token)
    encoded_auth_string = base64.b64encode(auth_string.encode("utf-8")).decode("utf-8")
    server._shortcmd("AUTH XOAUTH2")
    server._shortcmd(encoded_auth_string)
    num_messages = len(server.list()[1])
    for i in range(num_messages):
        response, lines, octets = server.retr(i + 1)
        msg_content = b"\n".join(lines)
        msg = email.message_from_bytes(msg_content)
        subject = msg.get("subject")
        from_email = msg.get("from")
        body_preview = ""
        if msg.is_multipart():
            for part in msg.walk():
                if part.get_content_type() == "text/plain":
                    body_preview = part.get_payload(decode=True).decode("utf-8")[:80]
                    break
        else:
            body_preview = msg.get_payload(decode=True).decode("utf-8")[:80]
        print(f"主题: {subject}")
        print(f"发件人: {from_email}")
        print(f"内容预览: {body_preview}")
        print(f"{'-'*50}")
    server.quit()

client_id = "YOUR_CLIENT_ID"
email_addr = "YOUR_EMAIL"
refresh_token = "YOUR_REFRESH_TOKEN"
access_token = get_access_token(client_id, refresh_token)
connect_pop3(email_addr, access_token)