-
Notifications
You must be signed in to change notification settings - Fork 242
Increase e-mail reminder function #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # -*- coding:utf-8 -*- | ||
|
|
||
| """ | ||
| @time: 2018-01-17 | ||
| @author: Skyge | ||
| """ | ||
|
|
||
| """ | ||
| Function: | ||
| If book tickets successfully,then send an email to notice you! | ||
| """ | ||
|
|
||
| import smtplib | ||
| from email.header import Header | ||
| from email.mime.text import MIMEText | ||
|
|
||
| mail_host = "smtp.163.com" # SMTP服务器 | ||
| mail_user = "[email protected]" # 用户名 | ||
| mail_pass = "xxx" # 授权密码(非登录密码) | ||
|
|
||
| sender = "[email protected]" # 发件人邮箱 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 可否支持其他类型邮箱邮件?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 应该也可以,我只是拿163邮箱举了个栗子。晚些时候我可以试一试。
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 晚些时候又注册了一些新的邮箱测试了一下,现总结如下: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 本人测试得到QQ邮箱不需要授权密码,直接用QQ密码就能登录 |
||
| receivers = "[email protected]" # 接收邮件 | ||
|
|
||
| content = "您已成功预定车票,请及时支付完成订单!" # 邮件内容 | ||
| title = "12306订票通知" # 邮件主题 | ||
|
|
||
| def send_email(): | ||
|
|
||
| message = MIMEText(content, "plain", "utf-8") # 内容, 格式, 编码 | ||
| message["From"] = "{}".format(sender) | ||
| message["To"] = ",".join(receivers) | ||
| message["Subject"] = title | ||
|
|
||
| try: | ||
| smtpObj = smtplib.SMTP_SSL(mail_host, 465) # 启用SSL发信, 端口一般是465 | ||
| smtpObj.login(mail_user, mail_pass) # 登录验证 | ||
| smtpObj.sendmail(sender, receivers, message.as_string()) # 发送 | ||
| print("mail has been send successfully.") | ||
| except smtplib.SMTPException as e: | ||
| print(e) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方只支持授权密码吗?如果使用非163邮箱这个授权码就无效了,通用性是不是差了点?