Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- import shutil
- import emails # sudo pip install emails
- from emails.template import JinjaTemplate as T
- file = open('email.txt', 'r') # reading email string from the user`s .txt file
- # userm = str(file.read()) # allocating variable and casting the read result, if required
- userm = file.read() # read the file content, no variable casting in this case
- print (userm) # checking the content
- message = emails.html(subject=T('Data processing request{{ billno }}'),
- html=T('<p>Dear {{ name }}! Your genomics data have been processed, download the attached files and look at your genome annotations, please'),
- mail_from=('Genomics data processor', 'XXXXXXXXXXX'))
- message.send(to=('Scientist', userm), # second argument is a email of the user coming from the .txt file
- render={'name': 'Scientist', 'billno': '777'})
- message.attach(data=open('processedfiles.zip', 'rb'), filename='YourGenomeProcessedAnnotations.zip', content_disposition='inline')
- m = message.as_message()
- s = message.as_string()
- r = message.send(to=('Scientist', userm), # second argument is a email of the user coming from the .txt file
- render={'name': 'Scientist'},
- smtp={'host':'smtp.yandex.com', 'port': 465, 'ssl': True, 'user': 'XXXXXXXXXX', 'password': 'XXXXXXX'}) # Write your own credentials here
- assert r.status_code == 250
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement