python 郵件自動傳送客戶端

2021-06-01 06:32:05 字數 1382 閱讀 6965

日常維護中經常會遇到自動提醒功能,我們目前已經有簡訊提醒。但是簡訊提醒的資訊量太少。故編寫了郵件傳送指令碼。

#!/usr/local/bin/python3

#-*- encoding: utf-8 -*-

import smtplib

from email.header import header

from email.mime.text import mimetext

from email.mime.multipart import mimemultipart

import sys

import os

smtp_server='smtp.gmail.com'

smtp_user='***'

smtp_pwd='***'

def mailmsgsend(from_addr, to_addr, subject, confile, attfile):

msg = mimemultipart()

msg.attach(mimetext(open(confile,'r').read(),'plain','gb2312'))

msg['to'] = ';'.join(to_addr)

msg['from'] = from_addr

msg['subject']= header(subject, 'utf-8')

try:

s = smtplib.smtp_ssl(smtp_server)

s.login(smtp_user, smtp_pwd)

send_msg = msg.as_string()

s.sendmail(msg['from'], msg['to'], send_msg)

s.close()

return true

except exception as e:

print(str(e))

return false

if __name__ == '__main__':

from_address = '***@gmail.com'

mailto_list=["***@asiainfo-linkage.com"

,"***@asiainfo-linkage.com"

confile = sys.argv[1]

attfile = sys.argv[2]

try:

if mailmsgsend(from_address, mailto_list,'程式**更改郵件', confile, attfile):

print('成功傳送郵件')

else:

print('傳送郵件失敗')

except exception as e:

print(str(e))

umeng推送客戶端沒收到

判斷是否是主程序 return int pid android.os.process.mypid if processname null return getpackagename equalsignorecase processname public static string getproces...

客戶端發郵件

smtp郵件傳送協議 手動給某乙個163郵箱發信 步驟1 找到email儲存郵件的伺服器 步驟2 連線伺服器,用smtp協議與之對話 cmd nslookup q mx 163.com 查到163伺服器 telnet 163mx02.mxmail.netease.com 25 smtp走的埠是25 ...

郵件客戶端 gmail hotmail

失敗的經歷 1.先使用outlook express 6.0 結果gmail可以用,但是hotmail用不了,hotmail只能在頁面上用,要在客戶端用的話需要有郵件伺服器 2.第二天搜了一下,聽說foxmail可以收hotmail的郵件,於是下了乙個foxmail 6.0正式版,結果發現只有fox...