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

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。