jaredmail.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import chz_gmaillib
  2. import dataset
  3. import datetime
  4. import random
  5. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  6. lst=[]
  7. cliend_id='db'
  8. campaign='20220504'
  9. #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')
  10. 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')
  11. for c in cursor:
  12. lst.append(c)
  13. #lst=[{'id':129,'email':'jared@choozmo.com','title':'集仕多'}]
  14. #lst=[{'id':125,'email':'jeweiliang@gmail.com','title':'風向數據'}]
  15. lst=[{'id':992,'email':'wizer@choozmo.com','title':'集仕多Wizer '}]
  16. table=db['emaillog']
  17. for c in lst:
  18. mailobj={}
  19. # r=random.randint(0,2)
  20. r=0
  21. if r==0:
  22. mailobj['gmail_user']='jared@choozmo.com'
  23. mailobj['gmail_password']='jgferbhelzrtgsbb'
  24. elif r==1:
  25. mailobj['gmail_user']='service@choozmo.com'
  26. mailobj['gmail_password']='umueijckijzmbpco'
  27. else:
  28. mailobj['gmail_user']='moi@choozmo.com'
  29. mailobj['gmail_password']='nlhfflrzbbfrbkcg'
  30. print(mailobj['gmail_user'])
  31. # gmail_user = 'jared@choozmo.com'
  32. # gmail_password='jgferbhelzrtgsbb'
  33. # gmail_user = 'service@choozmo.com'
  34. # gmail_password='umueijckijzmbpco'
  35. mailobj['toaddr']=c['email']
  36. # mailobj['title']=c['title']+'x ChoozMo 合作洽談 '
  37. # mailobj['title']=c['title']+'x ChoozMo 元宇宙策展需求旺盛 '
  38. mailobj['title']=c['title']+'x ChoozMo 媒體約訪的機會 '
  39. display={}
  40. display['custname']=c['title']
  41. display['client']=c['id']
  42. display['email']=mailobj['toaddr']
  43. display['campaign']=campaign
  44. mailobj['display']=display
  45. chz_gmaillib.mail_to_other(mailobj)
  46. table.insert({'email':c['email'],'title':c['title'],'cliend_id':cliend_id,'campaign':campaign,'dt':datetime.datetime.now()})