Skip to content

Commit

Permalink
Updated pyami_sendmail to offer more options, including HTML formatting
Browse files Browse the repository at this point in the history
email and not appending the instance id
  • Loading branch information
kopertop committed Jul 15, 2011
1 parent 59d6976 commit 29b4161
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/pyami_sendmail
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ if __name__ == "__main__":
parser.add_option("-t", "--to", help="Optional to address to send to (default from your boto.cfg)", action="store", default=None, dest="to")
parser.add_option("-s", "--subject", help="Optional Subject to send this report as", action="store", default="Report", dest="subject")
parser.add_option("-f", "--file", help="Optionally, read from a file instead of STDIN", action="store", default=None, dest="file")
parser.add_option("--html", help="HTML Format the email", action="store_true", default=False, dest="html")
parser.add_option("--no-instance-id", help="If set, don't append the instance id", action="store_false", default=True, dest="append_instance_id")

(options, args) = parser.parse_args()
if options.file:
body = open(options.file, 'r').read()
else:
body = sys.stdin.read()

notify(options.subject, body=body, to_string=options.to)
if options.html:
notify(options.subject, html_body=body, to_string=options.to, append_instance_id=options.append_instance_id)
else:
notify(options.subject, body=body, to_string=options.to, append_instance_id=options.append_instance_id)

0 comments on commit 29b4161

Please sign in to comment.