123456789101112131415161718192021222324 |
- import smtplib
- from email.mime.text import MIMEText
- # 设置邮箱信息
- smtp_server = 'smtp.gmail.com'
- smtp_port = 587
- sender_email = 'zooey@choozmo.com'
- sender_password = 'bnufmjzkyezputip'
- receiver_email = 'mia@choozmo.com'
- # 创建邮件内容
- subject = '註冊信'
- message = f"test"
- msg = MIMEText(message)
- msg['Subject'] = subject
- msg['From'] = sender_email
- msg['To'] = receiver_email
- # 连接到 SMTP 服务器并发送邮件
- with smtplib.SMTP(smtp_server, smtp_port) as server:
- server.starttls() # 开启 TLS 加密(如果需要)
- server.login(sender_email, sender_password)
- server.sendmail(sender_email, receiver_email, msg.as_string())
- print("Email sent successfully")
|