123456789101112131415161718192021222324252627282930313233343536373839 |
- import emails
- import smtplib
- from emails.template import JinjaTemplate
- # message = emails.Message(
- # subject=JinjaTemplate(subject_template),
- # html=JinjaTemplate(html_template),
- # mail_from=(settings.EMAILS_FROM_NAME, settings.EMAILS_FROM_EMAIL),
- # )
- message = f"test"
- subject = '註冊信'
- email_to ='oak@choozmo.com'
- # print('EEmail',email_to)
- message = emails.Message(
- subject=JinjaTemplate(message),
- html=JinjaTemplate(subject),
- mail_from=('zooey','zooey@choozmo.com'),
- )
- smtp_options = {"host": "smtp.gmail.com", "port": "587"}
- smtp_options["tls"] = True
- #smtp_options["ssl"] = True
- smtp_options["user"] = 'zooey@choozmo.com'
- smtp_options["password"] = 'bnufmjzkyezputip'
- environment={}
- print(email_to,environment,smtp_options)
- response = message.send(to=email_to, render=environment, smtp=smtp_options)
- print('RResponse',response)
- server = smtplib.SMTP()
- server.connect('smtp.gmail.com')
- server.login('zooey@choozmo.com','bnufmjzkyezputip')
- server.sendmail('zooey@choozmo.com', email_to,'hi 你好')
- server.quit()
|