Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2018
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import socket
  2. import base64
  3. import time
  4. import ssl
  5.  
  6. #Variables
  7. host,port = "smtp.gmail.com",465
  8. username = "minzylady0305@gmail.com"
  9. password = "laptopvaio0305"
  10. mailserver = (host,port)
  11.  
  12. clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  13. try:
  14. clientSocket = ssl.wrap_socket(clientSocket)
  15. clientSocket.connect(mailserver)
  16. print "Connect Success.."
  17. except:
  18. print "Connect Failed.."
  19.  
  20. recv = clientSocket.recv(1024).decode()
  21. if recv[:3] !="220":
  22. print "Error"
  23. else:
  24. print recv
  25.  
  26. #Hello
  27. helloCommand = "EHLO Alice\r\n"
  28. clientSocket.send(helloCommand.encode())
  29. recv = clientSocket.recv(1024).decode()
  30.  
  31. if recv[:3]!="250":
  32. print "ERROR"
  33. else:
  34. print recv
  35.  
  36. #Send username + password base64
  37.  
  38. auth = ("\x00"+username+"\x00"+password).encode()
  39. base64_auth = base64.base64_auth(auth)
  40. authMessage = "AUTH PLAIN " + base64_auth +"\r\n"
  41.  
  42. clientSocket.send(authMessage.encode())
  43. recv = clientSocket.recv(1024).decode()
  44. print recv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement