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

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