python 中没有密码的邮件
Mail without password in python
我想使用 python 向多个 ID 发送邮件。我正在使用 smtplib 发送它。我不想在脚本中提供我的密码。但是
smtp.login(username,password)
如果我不这样做就会失败。有没有其他图书馆可以这样做。
在哪里/如何存储凭据是一个广泛/大的问题。我喜欢的一种方法是使用这样的环境变量:
# In shell (to set the variable):
$ export MY_SMTP_PASS="this is a secret password"
# In python, to access it:
import os
smtp.login(username,os.environ['MY_SMTP_PASS'])
显然还有很多其他事情你可能想做,检查它是否在使用前设置(引发异常)等...
我想使用 python 向多个 ID 发送邮件。我正在使用 smtplib 发送它。我不想在脚本中提供我的密码。但是
smtp.login(username,password)
如果我不这样做就会失败。有没有其他图书馆可以这样做。
在哪里/如何存储凭据是一个广泛/大的问题。我喜欢的一种方法是使用这样的环境变量:
# In shell (to set the variable):
$ export MY_SMTP_PASS="this is a secret password"
# In python, to access it:
import os
smtp.login(username,os.environ['MY_SMTP_PASS'])
显然还有很多其他事情你可能想做,检查它是否在使用前设置(引发异常)等...