python-3.x - 从 python 向特定的 Outlook 电子邮件发送电子邮件回复
问题描述
我在我的项目中添加了 Outlook 邮件解析功能。现在我想使用 python 代码回复特定的电子邮件。
这个怎么做?
解决方案
这是我的看法。我认为应该明确设置“回复”标题。可能的原因是它不如“主题”、“收件人”和“发件人”等标题使用得少。
python
Python 2.6.6 (r266:84292, May 10 2011, 11:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> MAIL_SERVER = 'smtp.domain.com'
>>> TO_ADDRESS = 'you@gmail.com'
>>> FROM_ADDRESS = 'email@domain.com'
>>> REPLY_TO_ADDRESS = 'email2@domain2.com'
>>> import smtplib
>>> import email.mime.multipart
>>> msg = email.mime.multipart.MIMEMultipart()
>>> msg['to'] = TO_ADDRESS
>>> msg['from'] = FROM_ADDRESS
>>> msg['subject'] = 'testing reply-to header'
>>> msg.add_header('reply-to', REPLY_TO_ADDRESS)
>>> server = smtplib.SMTP(MAIL_SERVER)
>>> server.sendmail(msg['from'], [msg['to']], msg.as_string())
{}
推荐阅读
- android - 从另一个活动的堆栈中清除活动
- mongodb - 猫鼬覆盖原始对象而不是更新
- vuetify.js - Vuetify - 组件内部的 CSS 不起作用(生效)
- sql-server - 将查询总和转为排名列
- elasticsearch - logstash 无法从 kafka 正确读取 avro 记录
- tensorflow - Jupyter Notebook 在使用 MaxPool 层时被杀死
- java - 2个线程在java中一次启动
- ethereum - web3.py 中 sendTransaction 和 sendRawTransaction 的区别
- c++ - SDL2 窗口是透明的
- r - How to define blocks of elements in a vector to zero and looping over the next blocks?