2014-05-15 30 views
0

我想通過經過身份驗證的http代理在python中使用chilkat mailman api發送電子郵件。我儘可能按照Chilkat docs的說明操作,但是在代理服務器方面存在問題。我已經驗證了這個代理使用phantomjs腳本給定了指定的端口和auth。使用經過身份驗證的HTTP代理髮送帶有Chilkat Mailman的郵件

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("[email protected]") 
email.AddTo("Chris Johnson","[email protected]") 

# 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() 

如果我拿出設置代理的部分,郵件成功發送。是否還有一些其他屬性我缺少?

回答

0

儘管Chillkat的郵遞員支持HTTP代理,但它似乎不支持純HTTP代理。主要是,您使用的代理還必須支持其他協議,因爲SMTP不會通過HTTP進行廣播。由於我的代理只支持HTTP協議,所以它不適用於我。我交換使用SOCKS代理,現在一切工作正常。

相關問題