Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import sys
  2. import os
  3. import shutil
  4. import emails # sudo pip install emails
  5. from emails.template import JinjaTemplate as T
  6.  
  7.  
  8. file = open('email.txt', 'r') # reading email string from the user`s .txt file
  9.  
  10. # userm = str(file.read()) # allocating variable and casting the read result, if required
  11.  
  12. userm = file.read() # read the file content, no variable casting in this case
  13.  
  14. print (userm) # checking the content
  15.  
  16. message = emails.html(subject=T('Data processing request{{ billno }}'),
  17. html=T('<p>Dear {{ name }}! Your genomics data have been processed, download the attached files and look at your genome annotations, please'),
  18. mail_from=('Genomics data processor', 'XXXXXXXXXXX'))
  19.  
  20. message.send(to=('Scientist', userm), # second argument is a email of the user coming from the .txt file
  21. render={'name': 'Scientist', 'billno': '777'})
  22. message.attach(data=open('processedfiles.zip', 'rb'), filename='YourGenomeProcessedAnnotations.zip', content_disposition='inline')
  23. m = message.as_message()
  24. s = message.as_string()
  25. r = message.send(to=('Scientist', userm), # second argument is a email of the user coming from the .txt file
  26. render={'name': 'Scientist'},
  27. smtp={'host':'smtp.yandex.com', 'port': 465, 'ssl': True, 'user': 'XXXXXXXXXX', 'password': 'XXXXXXX'}) # Write your own credentials here
  28. assert r.status_code == 250
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement