--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xmpp-headline.py Sun Jul 10 10:58:40 2016 +0000
+from __future__ import print_function
+class SendMsgBot(sleekxmpp.ClientXMPP):
+ def __init__(self, jid, password, recipient, efrom, esubject):
+ super(SendMsgBot, self).__init__(jid, password)
+ self.recipient = recipient
+ self.esubject = esubject
+ self.add_event_handler('session_start', self.start)
+ def start(self, event):
+ print('sending message...')
+ msubject='New email: %s' % self.esubject,
+ mbody='%s from %s' % (self.esubject, self.efrom))
+ print('disconnecting...')
+ self.disconnect(wait=True)
+ jid = 'emailbot@example.com'
+ to = 'john@example.com'
+ efrom = sys.argv[1] or '(unknown)'
+ esubject = sys.argv[2] or '(no subject)'
+ xmpp = SendMsgBot(jid, password, to, efrom, esubject)
+ xmpp.process(block=True)
+ print('connection failed.')
+if __name__ == '__main__':