-
-
Save shelson/6d4dfd3b19451fde7cb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
############################################################################# | |
# This program is not part of Zenoss Core, an open source monitoring | |
# platform. It was adapted from zensnpp. | |
# Copyright (C) 2008, Zenoss Inc. | |
# Nick Anderson <nick@cmdln.org> | |
# | |
# This program is free software; you can redistribute it and/or modify it | |
# under the terms of the GNU General Public License version 2 as published by | |
# the Free Software Foundation. | |
# | |
# For complete information please visit: http://www.zenoss.com/oss/ | |
############################################################################# | |
import smtplib | |
import sys | |
import Globals | |
from transaction import commit | |
from Products.ZenUtils.ZenScriptBase import ZenScriptBase | |
dmd = ZenScriptBase(connect=True).dmd | |
print dmd.smtpHost | |
# Get arguments | |
def main(): | |
usage = "%prog [options] <smtp host> <10digit@carrier>" | |
parser = OptionParser(usage=usage) | |
parser.add_option("-u", "--user", dest="username", | |
help="smtp auth username") | |
parser.add_option("-p", "--pass", dest="password", | |
help="smtp auth password") | |
(options, args) = parser.parse_args() | |
try: | |
smtp = args[0] | |
rcpt = args[1] | |
except: | |
parser.error("smtp server and recipent required") | |
sys.exit(1) | |
# Read message from standard in | |
msg = sys.stdin.read() | |
# Send the sms | |
try: | |
s = smtplib.SMTP(smtp) | |
if options.username: | |
s.login(options.username, options.password) | |
s.sendmail('devnull@senderdomain', rcpt, msg) | |
s.quit() | |
except (): | |
print 'error sending sms' | |
sys.exit(1) | |
print "SMS sent to '%s'!" % rcpt | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment