import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from random import randint def send_verification_code(receiver_email): verification_code = str(randint(100000, 999999)) sender_email = 'xxxxx@gwpst.com' sender_password = 'E774B12D45c53ED6' subject = '验证码' message = f'您的验证码是: {verification_code}' # 创建邮件 email = MIMEMultipart() email['From'] = sender_email email['To'] = receiver_email email['Subject'] = subject # 添加邮件内容 email.attach(MIMEText(message, 'plain')) with smtplib.SMTP_SSL('smtp.cecloud.com', 465) as smtp: smtp.login(sender_email, sender_password) smtp.sendmail(sender_email, receiver_email, email.as_string()) # 示例调用 send_verification_code('1233@qq.com')#需要发到的邮箱
python 发送邮件
最新推荐文章于 2024-08-29 15:41:11 发布