域名免费企业邮箱是指通过注册并使用第三方提供的免费企业邮箱服务,使企业能够拥有以自己域名为后缀的电子邮箱地址。这种邮箱服务通常包含一系列企业级功能,如邮件收发、联系人管理、日程安排等。
import smtplib
from email.mime.text import MIMEText
# 邮件配置
smtp_server = 'smtp.example.com'
smtp_port = 587
sender_email = 'your_email@example.com'
receiver_email = 'receiver_email@example.com'
password = 'your_password'
# 创建邮件对象
msg = MIMEText('这是一封测试邮件')
msg['Subject'] = '测试邮件'
msg['From'] = sender_email
msg['To'] = receiver_email
# 发送邮件
try:
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, [receiver_email], msg.as_string())
server.quit()
print('邮件发送成功')
except Exception as e:
print(f'邮件发送失败: {e}')
领取专属 10元无门槛券
手把手带您无忧上云