Advertisement
Guest User

Untitled

a guest
Mar 17th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import paramiko
  2. ssh=paramiko.SSHClient()
  3. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  4. ssh.connect('hostname', port=22, username= 'xxxxx', password='yyyy')
  5. stdin, stdout, stderr = ssh.exec_command('sh ip int brief')
  6. output = stdout.read()
  7. print "n".join(output)
  8. import smtplib
  9. sender = 'xxxx@gmail.com'
  10. receivers = ['yyy@gmail.com','zzz@gmail.com']
  11.  
  12. body = "n" + output + "n"
  13. message = """From: From Person <xxxx@gmail.com>
  14. To: To Person <yyy@gmail.com>
  15. Subject: SMTP e-mail test
  16.  
  17. This is a test e-mail message from jay.
  18. """
  19.  
  20. try:
  21. smtpObj = smtplib.SMTP('smtp.com')
  22. smtpObj.sendmail(sender, receivers, message)
  23. print "Successfully sent email"
  24. except Exception:
  25. print "Error: unable to send email"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement