#!/usr/bin/python
# -*- coding: utf-8 -*-
from
email
.
mime
.
text
import
MIMEText
from
email
.
header
import
Header
from
smtplib
import
SMTP_SSL
import
sys
smtpaddr
=
'smtp.qq.com'
myemail
=
'admin@qq.com'
password
=
'123456'
recvmail
=
sys
.
argv
[
1
]
subject
=
sys
.
argv
[
2
]
content
=
sys
.
argv
[
3
]
# recvmail='admin@qq.com'
# subject='test'
# content='11111'
msg
=
MIMEText
(
"""%s"""
%
(
content
)
,
"plain"
,
"utf-8"
)
msg
[
'Subject'
]
=
Header
(
subject
,
'utf-8'
)
.
encode
(
)
msg
[
'From'
]
=
myemail
msg
[
'To'
]
=
recvmail
try
:
smtp
=
SMTP_SSL
(
smtpaddr
)
smtp
.
login
(
myemail
,
password
)
smtp
.
sendmail
(
myemail
,
recvmail
.
split
(
','
)
,
msg
.
as_string
(
)
)
smtp
.
quit
(
)
print
(
"success"
)
except
Exception
as
e
:
print
(
"fail: "
+
str
(
e
)
)
zabbix配置