#!/usr/bin/python

#coding:utf-8

import smtplib

import string

HOST="smtp.139.com"

SUBJECT="alarm email from python"

TO="mailaddress@139.com"               #利用139邮箱短信功能,当有人登录服务器可以短信报警

FROM="mailaddress@139.com"

text="check your computer someone login!"

BODY=string.join((

             "From:%s"%FROM,

              "To:%s"%TO,

              "Subject:%s"%SUBJECT,

               "",

               text),"\r\n")

server=smtplib.SMTP()

server.connect(HOST,"25")

server.login("yourmail@139.com","mailpassword")

server.sendmail(FROM,[TO],BODY)

server.quit()