0

I am trying to send emails using the chilkat mailman api in python, through an authenticated http proxy. I have followed the instructions from the Chilkat docs to the best of my ability but am having issues with the proxy server. I have verified that this proxy works given the specified port and auth using phantomjs scripts.

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

If I take out the section that sets the proxy, the mail is successfully sent. Is there some other attribute I am missing?

Comart
  • 64
  • 2
  • 8

1 Answers1

0

Though Chillkat's mailman has support for HTTP proxies, it seems that it doesn't support pure HTTP proxies. Mainly, the proxy that you use must also support other protocols because SMTP doesn't broadcast over HTTP. As my proxy only supported HTTP protocol, it wouldn't work for me. I swapped to use a SOCKS proxy and now everything is working fine.

Comart
  • 64
  • 2
  • 8