关于通过 python 发送电子邮件的两个问题(RFC822,登录信息)

发布于 2024-07-13 12:33:10 字数 236 浏览 7 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ま柒月 2024-07-20 12:33:10

To:Cc: 标头中的列表使用 ', '.join(),但标头仅用于显示。 决定邮件实际去往何处的是 RCPT 信封。 假设您正在使用 smtplib,这是第二个参数:

connection.sendmail(senderaddress, to.split(), mailtext)

2:这是可能的,但远非直截了当。 浏览器不希望外部程序查看其安全敏感的存储数据。

Use ', '.join() for the list in the To: or Cc: 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:

connection.sendmail(senderaddress, to.split(), mailtext)

2: it's possible, but far from straightforward. Browsers don't want external programs looking at their security-sensitive stored data.

笑脸一如从前 2024-07-20 12:33:10

对于问题的第二部分,您可以查看 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文