FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UserPyScript/monitor/utils.py at master · youerning/UserPyScript · GitHub
youerning
/
UserPyScript
Public
Notifications
You must be signed in to change notification settings
Fork
19
Star
34
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
UserPyScript
/
monitor
/
utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (50 loc) · 1.48 KB
Breadcrumbs
UserPyScript
/
monitor
/
utils.py
Copy path
File metadata and controls
60 lines (50 loc) · 1.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#coding: utf-8
import
sys
import
smtplib
from
functools
import
wraps
from
email
.
mime
.
text
import
MIMEText
from
configparser
import
ConfigParser
confile
=
"monitor.conf"
conf
=
ConfigParser
()
conf
.
read
(
confile
)
smtpServer
=
"smtp.163.com"
reciver
=
conf
[
"mail"
][
"reciver"
]
smtpUser
=
conf
[
"mail"
][
"username"
]
smtpPass
=
conf
[
"mail"
][
"password"
]
sender
=
smtpUser
# 126 mail server treat the message contain string "test" like Spam.
testMsg
=
"this is a email for 126 and for someone use the email script."
def
cache
(
func
):
data
=
{}
@
wraps
(
func
)
def
wrapper
(
*
args
):
if
args
in
data
:
return
data
[
args
]
else
:
res
=
func
(
*
args
)
data
[
args
]
=
res
return
res
return
wrapper
def
sendMail
(
subject
,
message
):
server
=
smtplib
.
SMTP
()
server
.
connect
(
smtpServer
)
# server.set_debuglevel(1)
# server.ehlo()
# server.starttls()
# server.ehlo()
server
.
login
(
smtpUser
,
smtpPass
)
# server.set_debuglevel(1)
msg
=
MIMEText
(
message
,
"plain"
,
"utf8"
)
msg
[
"Subject"
]
=
subject
msg
[
"From"
]
=
smtpUser
msg
[
"To"
]
=
reciver
server
.
sendmail
(
smtpUser
, [
reciver
],
msg
.
as_string
())
server
.
quit
()
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
"-t"
:
sendMail
(
"monitor message for stock"
,
testMsg
)
else
:
try
:
sendMail
(
*
sys
.
argv
[
1
:])
except
Exception
as
e
:
pass
Back
|
FazBrowse Home
|
New Git URL