banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

Python寫郵箱群發廣告機

首先创建四个文件 title.txt,content.txt,smtp.py,qq.txt

image
其中 title.txt 文本裡面放置郵箱的標題,例如:

image
content.txt 文本放置郵件內容,例如:

image
qq.txt 放置發送的郵箱號碼,例如:

image

smtp.py 代碼#


import smtplib
from email.mime.text import MIMEText
from email.header import Header

while True:
    # 郵件登錄信息
    email_user = '你的qq郵箱'
    email_password = '你的授權碼'

    # 讀取收件人列表
    with open('qq.txt', 'r') as file:
        recipient_list = file.readlines()

    # 去除每個收件人郵箱地址各自行末的換行符和空白字符
    recipient_list = [recipient.strip() for recipient in recipient_list]

    # 讀取郵件正文和主題
    with open('content.txt', 'r', encoding='utf-8') as file:
        body_text = file.read().strip()
    with open('title.txt', 'r', encoding='gbk') as file:
        title_text = file.read().strip()

    # 創建郵件內容
    msg = MIMEText(body_text, _subtype='html', _charset='utf-8')
    msg['From'] = email_user
    msg['Subject'] = Header(title_text.encode('utf-8'), 'utf-8').encode()

    # 連接到SMTP服務器
    with smtplib.SMTP_SSL('smtp.qq.com', 465) as server:
        server.login(email_user, email_password)

        # 發送郵件給每個收件人
        for recipient in recipient_list:
            try:
                server.sendmail(email_user, recipient, msg.as_string())
                print(f'[*] 郵件已成功發送到 {recipient}')
            except smtplib.SMTPDataError as e:
                if e.smtp_code == 550:
                    print(f'[!] 郵件發送到 {recipient} 失敗:{e.smtp_error}')
                elif e.smtp_code == 501:
                    print(f'[!] 郵件發送到 {recipient} 失敗:收件人地址存在語法錯誤')
                else:
                    print(f'[!] 發送郵件時發生錯誤:{e}')

    print('[*] 所有郵件均已發送完畢。')

    # 顯示提示消息,並等待用戶輸入yes或no以確定是否發送更多電子郵件
    answer = input("是否要再次發送電子郵件(yes/no)? ")

    # 如果用戶選擇“no”,則退出程序,否則繼續發送電子郵件
    if answer.lower() == 'no':
        print("程序已經關閉。")
        break
    else:
        continue

前提是要開啟 QQ 郵箱 POP3, SMTP 服務和獲取服務授權碼 (密碼)
163 郵箱都一樣的。。
登錄 qq 郵箱 官網:https://mail.qq.com/
登錄 / 註冊成功後到郵箱首頁點擊左側的設置

image

點擊帳戶
image
下拉帳戶頁面並找到圖中紅框圈的內容,點擊開啟

image
這串宇母就是授權碼

image
授權碼和郵箱填在代碼塊裡面:

email_user = '你的qq郵箱'
email_password = '你的授權碼'

下面用 Python 寫了一個批量生成郵箱

import random
import string

def generate_random_email():
    domain = 'qq.com'
    username = ''.join(random.choices(string.ascii_letters + string.digits, k=8))
    email = username + '@' + domain
    return email

random_emails = []
for _ in range(100):
    random_emails.append(generate_random_email())

for email in random_emails:
    print(email)
#這段代碼將生成100個隨機的QQ郵箱地址,並將其打印出來。每個郵箱地址的用戶名長度為8位。您可以根據需要自定義用戶名的長度和郵箱的域名

這裡生成 100 個 8 位 QQ 郵箱,生成的郵箱會保存本目錄下 qq.txt 文本文件中
開始進行批量發送,不存在的郵箱這邊會略過下一個繼續發送

image

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。