Send mail function function
1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 ImportSmtplib4 fromEmail.mime.textImportMimetext5 fromEmail.utilsImportformataddr6 defEmail (message):7msg = mimetext (Message,'Plain','Utf-8')8msg[' from'] = FORMATADDR (["Greatly",'[email protected]'])9msg[' to'] = FORMATADDR (["Little",' 2721593215@qq. com'])Tenmsg['Subject'] ="Ghost Valley Alarm System" One AServer = Smtplib. SMTP ("smtp.126.com", 25) -Server.login ("[email protected]","n1049759078") -Server.sendmail ('[email protected]', [' 2721593215. com',], msg.as_string ()) the server.quit () - if __name__=='__main__': -CPU = 100 -Disk = 80 +RAM = 60 - forIinchRange (1): + ifCPU > 80: AAl = u"There 's a problem with the CPU" at Email (AL) - ifDisk > 70: -Al = u"disk's gone wrong." - Email (AL) - ifRam > 90: -Al = u"There 's a problem with Ram" inEmail (All)
Python Send mail function module