Python使用Chilkat -- Password included

import urllib2

import urllib

import sys

import re

import math

import os

import time

import string

import datetime

import io

import lxml

import xmlrpclib

import PIL

import mimetypes

import socket

import shutil

import ConfigParser

import glob

import logging, logging.handlers

import binascii

import chilkat

import cgi


from BeautifulSoup import BeautifulSoup,NavigableString

from urllib2 import Request, urlopen, URLError, HTTPError

from types import *




for p in sys.argv:

   if(p.find("-host=") != -1):

       host = p.split("=")[1]

   if(p.find("-ssl=") != -1):

       ssl = p.split("=")[1]

   if(p.find("-port=") != -1):

       port = p.split("=")[1]    

   if(p.find("-username=") != -1):

       username = p.split("=")[1]

       displayname = username.split('@')[0]

   if(p.find("-password=") != -1):

       password = p.split("=")[1]

http = chilkat.CkHttp()

success = http.UnlockComponent("SVERTLEADHttp_qcaVzzoP4J6Y")

if (success != True):

   sys.exit()




def main():

   post_email = username

   mailman = chilkat.CkMailMan()

   #  Any string argument automatically begins the 30-day trial. CHRISSMAILQ_hSXBOYyQnU1Y | MAILT34MB34N_50D59A750UEU

   success = mailman.UnlockComponent("CHRISSMAILQ_hSXBOYyQnU1Y")

   if (success != True):

   print "Component unlock failed"

   sys.exit()

   

   #  Set the SMTP server.

   mailman.put_SmtpHost(host)

   # Set SSL properties:

   mailman.put_SmtpPort(int(port))

   mailman.put_SmtpSsl(ssl)

   

   #  Set the SMTP login/password (if required)

   ##mailman.put_SmtpUsername("dwilliamsweb@gmail.com")

   mailman.put_SmtpUsername(username)

   mailman.put_SmtpPassword(password)

   

   post_title = 'test new smtp account'

   

   #  Create a new email object

   email = chilkat.CkEmail()

   email.put_Subject("Re: " + post_title)

   email.AddTo(post_email,post_email)

   email.put_From(displayname + "<"+username+">")

   

   email_content = "Hi,\ntesting new smtp account"

   email.put_Body(email_content)

   

   success = mailman.SendEmail(email)

   if success == True:

   print 'success'

   else:

   print 'error'

   mailman.CloseSmtpConnection()

### 

if __name__ == "__main__":

   main()

posted @ 2017-02-27 14:45  F.Feng  阅读(388)  评论(0编辑  收藏  举报