jaredmail.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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='20220305-test'
  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. for c in cursor:
  11. lst.append(c)
  12. table=db['emaillog']
  13. for c in lst:
  14. mailobj={}
  15. r=random.randint(0,1)
  16. if r==0:
  17. mailobj['gmail_user']='jared@choozmo.com'
  18. mailobj['gmail_password']='jgferbhelzrtgsbb'
  19. else:
  20. mailobj['gmail_user']='service@choozmo.com'
  21. mailobj['gmail_password']='umueijckijzmbpco'
  22. # gmail_user = 'jared@choozmo.com'
  23. # gmail_password='jgferbhelzrtgsbb'
  24. # gmail_user = 'service@choozmo.com'
  25. # gmail_password='umueijckijzmbpco'
  26. mailobj['toaddr']=c['email']
  27. mailobj['title']=c['title']+'x ChoozMo 合作洽談 '
  28. display={}
  29. display['custname']=c['title']
  30. display['client']=c['id']
  31. display['email']=mailobj['toaddr']
  32. display['campaign']=campaign
  33. mailobj['display']=display
  34. chz_gmaillib.mail_to_other(mailobj)
  35. table.insert({'email':c['email'],'title':c['title'],'cliend_id':cliend_id,'campaign':campaign,'dt':datetime.datetime.now()})