jaredmail.py 888 B

1234567891011121314151617181920212223242526272829
  1. import chz_gmaillib
  2. import dataset
  3. import datetime
  4. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  5. lst=[]
  6. cliend_id='db'
  7. campaign='20220305-test'
  8. 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')
  9. for c in cursor:
  10. lst.append(c)
  11. table=db['emaillog']
  12. for c in lst:
  13. mailobj={}
  14. mailobj['toaddr']=c['email']
  15. mailobj['title']=c['title']+'x ChoozMo 合作洽談 '
  16. display={}
  17. display['custname']=c['title']
  18. display['client']=c['id']
  19. display['email']=mailobj['toaddr']
  20. display['campaign']=campaign
  21. mailobj['display']=display
  22. chz_gmaillib.mail_to_other(mailobj)
  23. table.insert({'email':c['email'],'title':c['title'],'cliend_id':cliend_id,'campaign':campaign,'dt':datetime.datetime.now()})