#!/bin/python3 import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText # 邮件配置 smtp_server = 'mail.ddoss.cn' # SMTP 服务器地址 smtp_port = 465 # SMTP 端口,587 是通常用于 TLS 加密的端口 smtp_user = 'system@ddoss.cn' # 发件人邮箱地址 smtp_password = 'ddoss.cn' # 发件人邮箱密码 # 收件人和发件人 from_address = 'system@ddoss.cn' to_address = 'okgcc@qq.com' # 创建邮件内容 msg = MIMEMultipart() msg['From'] = from_address msg['To'] = to_address msg['Subject'] = '测试注册验证码' # 邮件正文 body = '你的验证码是 eisc.cn ddoss.cn' msg.attach(MIMEText(body, 'plain')) # 发送邮件 try: with smtplib.SMTP_SSL(smtp_server, smtp_port) as server: server.login(smtp_user, smtp_password) # 登录 SMTP 服务器 server.send_message(msg) # 发送邮件 print('邮件发送成功') except Exception as e: print(f'邮件发送失败: {e}')
Powered by ddoss.cn 12.0
©2015 - 2024 ddoss
渝公网安备50011302222260号 渝ICP备2024035333号 【实验平台安全承诺书】 小绿叶技术社区,优化网络中,点击查看配置信息
您的IP:192.168.122.82,2024-10-10 19:05:50,Processed in 0.04309 second(s).