1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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='20220504'
- #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')
- cursor=db.query('select id,email,title from mail_list where enabled=1 and tag="新創" and email not in (select email from emaillog where campaign="'+campaign+'") order by rand() limit 1')
- for c in cursor:
- lst.append(c)
- #lst=[{'id':129,'email':'jared@choozmo.com','title':'集仕多'}]
- #lst=[{'id':125,'email':'jeweiliang@gmail.com','title':'風向數據'}]
- lst=[{'id':992,'email':'wizer@choozmo.com','title':'集仕多Wizer '}]
- table=db['emaillog']
- for c in lst:
- mailobj={}
- # r=random.randint(0,2)
- r=0
- if r==0:
- mailobj['gmail_user']='jared@choozmo.com'
- mailobj['gmail_password']='jgferbhelzrtgsbb'
- elif r==1:
- mailobj['gmail_user']='service@choozmo.com'
- mailobj['gmail_password']='umueijckijzmbpco'
- else:
- mailobj['gmail_user']='moi@choozmo.com'
- mailobj['gmail_password']='nlhfflrzbbfrbkcg'
- print(mailobj['gmail_user'])
- # 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 合作洽談 '
- # mailobj['title']=c['title']+'x ChoozMo 元宇宙策展需求旺盛 '
- 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()})
|