1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import chz_gmaillib
- import dataset
- import datetime
- import random
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- lst=[]
- cliend_id='db'
- campaign='20220305-test'
- cursor=db.query('select id,email,title from mail_list where enabled=1 and email not in (select email from emaillog where campaign="'+campaign+'") order by rand() limit 1')
- for c in cursor:
- lst.append(c)
- table=db['emaillog']
- for c in lst:
- mailobj={}
- r=random.randint(0,1)
- if r==0:
- mailobj['gmail_user']='jared@choozmo.com'
- mailobj['gmail_password']='jgferbhelzrtgsbb'
- else:
- mailobj['gmail_user']='service@choozmo.com'
- mailobj['gmail_password']='umueijckijzmbpco'
- # gmail_user = 'jared@choozmo.com'
- # gmail_password='jgferbhelzrtgsbb'
- # gmail_user = 'service@choozmo.com'
- # gmail_password='umueijckijzmbpco'
- mailobj['toaddr']=c['email']
- mailobj['title']=c['title']+'x ChoozMo 合作洽談 '
- display={}
- display['custname']=c['title']
- display['client']=c['id']
- display['email']=mailobj['toaddr']
- display['campaign']=campaign
- mailobj['display']=display
- chz_gmaillib.mail_to_other(mailobj)
- table.insert({'email':c['email'],'title':c['title'],'cliend_id':cliend_id,'campaign':campaign,'dt':datetime.datetime.now()})
|