- 论坛徽章:
- 4
|
个人想法,如果数据库的压力没有那么大,可以考虑使用datediff用sql得出有哪些需要被通知,然后,就只需要用python去一条条发邮件通知去了。
至于用python去发邮件,下面是找来的一个例子。- #!/usr/bin/python
- import smtplib
- sender = 'from@fromdomain.com'
- receivers = ['to@todomain.com']
- message = """From: From Person <from@fromdomain.com>
- To: To Person <to@todomain.com>
- MIME-Version: 1.0
- Content-type: text/html
- Subject: SMTP HTML e-mail test
- This is an e-mail message to be sent in HTML format
- <b>This is HTML message.</b>
- <h1>This is headline.</h1>
- """
- try:
- smtpObj = smtplib.SMTP('localhost')
- smtpObj.sendmail(sender, receivers, message)
- print "Successfully sent email"
- except SMTPException:
- print "Error: unable to send email"
复制代码 |
|