I'm trying to send an email to an SMTP server but I keep getting errors from the server. It says my commands are unrecognized with status codes like 500 and 501.
Here is my script:
import socket
server_info = ("smtp.gmx.com", 25)
socket = socket.socket()
socket.connect(server_info)
username = raw_input("Enter your username: ")
password = raw_input("Enter your password: ")
recipient = raw_input("Recipient: ")
data = raw_input("Your message: ")
auth = username + "" + password
auth = auth.encode("base64").replace("\n", "")
socket.send("HELO\r\n")
print "EHLO Response: " + socket.recv(1024)
socket.send("AUTH PLAIN "+auth+"\r\n")
print "AUTH Response: " + socket.recv(1024)
socket.send("MAIL FROM:<"+username+">\r\n")
print "MAIL FROM Response: " + socket.recv(1024)
socket.send("RCPT TO:"+recipient+"\r\n")
print "RCPT TO Response: " + socket.recv(1024)
socket.send("RCPT TO:"+recipient+"\r\n")
print "RCPT TO Response: " + socket.recv(1024)
socket.send("DATA\r\n")
print "DATA Response: " + socket.recv(1024)
socket.send(data + "\r\n.\r\n")
print "RAW DATA Response: " + socket.recv(1024)
socket.send("QUIT\r\n")
print "QUIT Response: " + socket.recv(1024)
print "Done."
socket.close()
What is the problem with these command? I wrote them exactly like they should be. Here is the errors I get from the server:
http://i.gyazo.com/3f5eb3a34cbb0f00510281bccc8d0546.png
P.S I don't want to use smtplib. I would like to send my email manually, for learning purposes