I have a script that runs at evening, it writes to a log file as it runs, and once the task completes, the text it writes is also emailed to me. Sometimes the task can fail, what I want to happen is when I get the email, the line with the error is red and bold.
So my question is, can Python format text to a certain font or color if certain conditions are met? If so, are there any good examples?
Thanks!
Python comes with the built-in smtplib module for sending emails using the Simple Mail Transfer Protocol (SMTP). smtplib uses the RFC 821 protocol for SMTP. The examples in this tutorial will use the Gmail SMTP server to send emails, but the same principles apply to other email services.
Simple Mail Transfer Protocol (SMTP) is a protocol, which handles sending e-mail and routing e-mail between mail servers. Python provides smtplib module, which defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon.
I think you could just add html tags to your email and send it as HTML. However it'll change the content of your text file as it'll write additional characters to change the styling.
EXAMPLE: Sending HTML email using Python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With