Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. def send_email():
  2. try:
  3. # Defining server variable as a gmail
  4. server = smtplib.SMTP('smtp.gmail.com:587')
  5. # Sending Extended SMTP (ESMTP) protocol setup to identify itself and initiate the SMTP conversation
  6. server.ehlo()
  7. # Server start and login based on credentials stored in config
  8. server.starttls()
  9. server.login(config.email_address, config.password)
  10. # Sets the message template and afterwards sends email
  11. for patient in database:
  12. 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)
  13. server.sendmail(config.email_address, patient[4], message)
  14. # After sending email we quit server
  15. server.quit()
  16. print("All Emails successfully sent")
  17. except:
  18. print("Email failed to send.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement