[python]Email script

#!/usr/bin/env python
import smtplib
import sys
from email.mime.text import MIMEText

lineitems = sys.stdin.readlines()
SERVER = "obfuscated.email.server"
FROM = "tufin-noreply@obfuscated.com"
TO = "admin@ofuscated.com"
CC = "xyz@obfuscated.com"

SUBJECT = "Test - Tufin securechange auto step stuck"
TEXT = "Dear admin,\r\
This message is generated for your attention that a step in tufin secure change \ is stucked.\r \
Manual intervention by you is required.\r\
On next version this message will add the tufin ticket number.\r\
This is a test message please IGNORE.\r\
%s " % (lineitem for line in lineitems)

message = MIMEText(TEXT)
message["From"] = FROM
message["To"] = TO
message["Subject"] = SUBJECT
message["Cc"] = CC
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message.as_string())
server.quit()

The above code snippet is an email script that is triggered when Tufin fails an automated step. The challenge now is to include a ticket number to the email.

Advertisements
This entry was posted in General stuffs. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s