我正在尝试使用python中的chilkat mailman api通过经过身份验证的http代理发送电子邮件。我已经尽我所能地遵循了Chilkat docs的说明,但代理服务器出现了问题。我已经使用phantomjs脚本验证了这个代理在给定指定的端口和身份验证的情况下可以正常工作。
import chilkat
# The mailman object is used for sending and receiving email.
mailman = chilkat.CkMailMan()
# set the http proxy
mailman.put_HttpProxyAuthMethod("LOGIN")
mailman.put_HttpProxyHostname("xxx.xxx.xxx.xxx")
mailman.put_HttpProxyPort(xxxxx)
mailman.put_HttpProxyUsername("xxxxx")
mailman.put_HttpProxyPassword("xxxxx")
# Set the SMTP server.
mailman.put_SmtpHost("smtp.live.com")
mailman.put_StartTLS(True)
mailman.put_SmtpPort(25)
# Set the SMTP login/password (if required)
mailman.put_SmtpUsername("xxxxxxx")
mailman.put_SmtpPassword("xxxxxxx")
# Create a new email object
email = chilkat.CkEmail()
email.put_Subject("This is a test")
email.put_Body("This is a test")
email.put_From("name@email.com")
email.AddTo("Chris Johnson","name@email.com")
# Call SendEmail to connect to the SMTP server via the HTTP proxy and send.
success = mailman.SendEmail(email)
if (success != True):
print(mailman.lastErrorText())
sys.exit()如果我去掉设置代理的部分,邮件就会成功发送。我还遗漏了什么其他属性吗?
发布于 2014-05-21 02:02:36
尽管Chillkat的mailman支持HTTP代理,但它似乎不支持纯HTTP代理。主要地,您使用的代理还必须支持其他协议,因为SMTP不通过HTTP广播。因为我的代理只支持HTTP协议,所以它不适用于我。我换用了SOCKS代理,现在一切正常。
https://stackoverflow.com/questions/23667185
复制相似问题