auto emailer
Project description
Emailer
Emailer provides
a decorator to send emails on error instead of raise an error
Emails will be constructed as MIMEMultipart contains only simple text. And sent throught smtp wihtout any authentication, which suitsmost of internal smtp servers.
Installation
Install with pip
pip install error-emailer
Email construct
Email constructed as MIMEMultipart with default
error_msg_title = 'Error'
error_msg_content = 'Error occurred'
Example: Use decorator
from erroremailer import EmailError
ee = EmailError(
from_addr = 'me@example.com',
to_addr = 'others@example.com',
smtp_addr = '10.0.0.1@some-smtp.com',
# set send_email to False for test
send_email = False,
error_msg_title = 'Error occured in my best script"
error_msg_content = 'Error occured in my best script"
)
@ee.email_on_error()
def make_a_error():
a = 1
b = '2'
print(a + b)
return a
make_a_error()
Example: Use send email directly
from erroremailer import EmailError
ee = EmailError(
from_addr = 'me@example.com',
to_addr = 'others@example.com',
smtp_addr = '10.0.0.1@some-smtp.com',
# set send_email to False for test
send_email = False,
error_msg_title = 'Error occured in my best script"
error_msg_content = 'Error occured in my best script"
)
def make_a_error():
a = 1
b = '2'
print(a + b)
return a
if __name__ == '__main__':
try:
make_a_error()
except:
ee.send_error_email()
finally:
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for error_emailer-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e089589770653f373bc04e402c602713e489f286e3d85c5b7dfec5720849822f |
|
MD5 | e7449d434179d0ab7b0ea942c611815d |
|
BLAKE2b-256 | aaa39ae67ceb524f20c67e74f29119507cbe7dfb71554b141ac7826580dc0497 |