Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def send_email():
- try:
- # Defining server variable as a gmail
- server = smtplib.SMTP('smtp.gmail.com:587')
- # Sending Extended SMTP (ESMTP) protocol setup to identify itself and initiate the SMTP conversation
- server.ehlo()
- # Server start and login based on credentials stored in config
- server.starttls()
- server.login(config.email_address, config.password)
- # Sets the message template and afterwards sends email
- for patient in database:
- message = 'Dear {},nnJust a friendly reminder that at {} you have a {} procedure at {}.nnThanksnBest regards,nn{}'.format(i[0],i[1],i[2],config.signature,config.signature)
- server.sendmail(config.email_address, patient[4], message)
- # After sending email we quit server
- server.quit()
- print("All Emails successfully sent")
- except:
- print("Email failed to send.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement