smstomail.cgi
资源名称:gateway-1.2.1 [点击查看]
上传用户:gzpyjq
上传日期:2013-01-31
资源大小:1852k
文件大小:1k
源码类别:
手机WAP编程
开发平台:
WINDOWS
- #!/usr/bin/python
- MAIL_SENDER = "liw"
- MAIL_RECEIVER = "liw"
- import cgi, os, string
- class Vars:
- def __init__(self):
- self._dict = cgi.FieldStorage()
- def __getitem__(self, key):
- return self._dict[key].value
- def smstomail():
- print "Content-Type: text/plain"
- print ""
- v = Vars()
- f = os.popen("/usr/sbin/sendmail -oi %s" % MAIL_RECEIVER, "w")
- f.write("From: %snTo: %snSubject: SMS message from %snn%s:n%sn" %
- (MAIL_SENDER, MAIL_RECEIVER, v["from"], v["to"], v["text"]))
- f.close()
- print "Sent via mail to receiver."
- if __name__ == "__main__":
- smstomail()