Ex邮箱域名通常是指企业或组织提供的电子邮件服务,其格式一般为 username@domain.com
。其中,username
是用户的邮箱账号,而 domain.com
则是邮箱的域名部分。
.com
、.org
、.net
等作为后缀。import smtplib
from email.mime.text import MIMEText
# 邮件发送者和接收者
sender = 'your_email@example.com'
receiver = 'receiver_email@example.com'
# 邮件内容
message = MIMEText('这是一封测试邮件', 'plain', 'utf-8')
message['From'] = sender
message['To'] = receiver
message['Subject'] = '测试邮件'
# 发送邮件
try:
smtpObj = smtplib.SMTP('smtp.example.com')
smtpObj.login(sender, 'your_password')
smtpObj.sendmail(sender, receiver, message.as_string())
print("邮件发送成功")
except smtplib.SMTPException as e:
print("Error: 无法发送邮件", e)
请注意,以上示例代码中的邮箱地址、SMTP 服务器地址和密码需要替换为实际使用的值,并确保 SMTP 服务器支持发送邮件。同时,为了保护个人隐私,建议不要在公共场合泄露邮箱密码等敏感信息。
没有搜到相关的文章