关于通过 python 发送电子邮件的两个问题(RFC822,登录信息)
1 -
在我的电子邮件发送脚本中,我将间隔的电子邮件存储在字符串中,然后使用“,”.join(to.split())。 然而,看起来脚本只发送到第一封电子邮件 - 这与 RFC822 格式有关吗? 如果是这样,我该如何解决这个问题?
2 -
当我的密码在我的脚本中可见时,我感觉有点急躁。 有没有办法从 cookie 或 Firefox 保存的密码中检索此信息?
提前致谢!
1 -
In my email-sending script, I store spaced-out emails in a string, then I use ", ".join(to.split()). However, it looks like the script only sends to the 1st email - is it something to do with RFC822 format? If so, how can I fix this?
2 -
I feel a bit edgy having my password visable in my script. Is there a way to retrieve this info from cookies or saved passwords from firefox?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对
To:
或Cc:
标头中的列表使用', '.join()
,但标头仅用于显示。 决定邮件实际去往何处的是 RCPT 信封。 假设您正在使用 smtplib,这是第二个参数:2:这是可能的,但远非直截了当。 浏览器不希望外部程序查看其安全敏感的存储数据。
Use
', '.join()
for the list in theTo:
orCc:
header, but the headers are only for show. What determines where the mail actually goes is the RCPT envelope. Assuming you're using smtplib, that's the second argument:2: it's possible, but far from straightforward. Browsers don't want external programs looking at their security-sensitive stored data.
对于问题的第二部分,您可以查看 netrc 模块 (http:// docs.python.org/library/netrc.html)。
这并不比在脚本中包含密码好多少,但它确实允许使用计算机的任何人都可以读取脚本,而您的主目录中的文件中只有您可以读取密码。
For the second part of your question, you could take a look at the netrc module (http://docs.python.org/library/netrc.html).
This isn't much better than having the password in the script, but it does allow the script to be readable for anyone using the computer, while you have the password in a file in your home directory that is only readable by you.