Skip to content

yaooolu/mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mail_alert

moniter project and send email when error occur (for python >3)

Installation

pip3 install mail_alert

useage

first create a config file named 'mail_settings.py' in your project root path and add the project root path to your sys.path or PYTHONPATH

config example

server = {
    'name': 'smtp.163.com', # smtp server addr
    'port': 465, # smtp server port
    'user': 'XXXX.com', # email
    'password': '', # passwd【for 163/qq email this password is not equal to web login       password, it's set by customer in the email config page】
    'ssl': True, # set False if port is not 25
}

default = ('y1150264176@163.com', 'yaolu0405@gmail.com') # send to email addr group

cc = ('y1150264176@163.com', ) # carbon copy addr group

decorate class:

monitor all functions in this class and send email when error occur

>>> from mail_alert import MailAlert
>>> @MailAlert(to="default", cc="cc")
>>> class A:
>>>    def hello(self):
>>>        1 / 0
>>>        return 'ss'

decorate function:

monitor this decorated function and send email when error occur

>>> from mail_alert import MailAlert
>>> class A:
>>>    @MailAlert(to="default", cc="cc")
>>>    def hello(self):
>>>        1 / 0
>>>        return 'ss'

arguments

the arguments will read from config file mail_settings.py

1、to : sendto email list

2、cc : carbon copy addr group

About

monitor project and send alert email when error occur

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages