企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 发送电子邮件 ``` import smtplib from email.mime.text import MIMEText # 第三方 SMTP 服务 mail_host = "smtp.qq.com" # SMTP服务器 mail_user = "XXXXXXXX@qq.com" # 用户名 mail_pass = "XXXXXXXXX" # 密码(这里的密码不是登录邮箱密码,而是授权码) sender = 'xxxxx@qq.com' # 发件人邮箱 #receivers = ['xxxxxx@qq.com','xxxx@qq.com']  # 接收人邮箱 receivers = ['xxxxx@yxxu.com']  # 接收人邮箱 content = '你好,有缘人,这是一封来自几分钟之前的邮件!' title = '你是有缘人2022' # 邮件主题 message = MIMEText(content, 'plain', 'utf-8')  # 内容, 格式, 编码 message['From'] = "{}".format(sender) message['To'] = ",".join(receivers) message['Subject'] = title try: smtpObj = smtplib.SMTP_SSL(mail_host, 465)  # 启用SSL发信, 端口一般是465 smtpObj.login(mail_user, mail_pass)  # 登录验证 smtpObj.sendmail(sender, receivers, message.as_string())  # 发送 print("mail has been send successfully.") except smtplib.SMTPException as e: print(e) ```