dude, it's not like i haven't tried. i can't figure out the issue with gmail. it won't let me use their smtp servers.
here's what i have so far: i removed my personal info from the code
from socket import * msg = "\r\n This is test email. This is where the message will appear" endmsg = "\r\n.\r\n"
recipient = "[email protected]" sender = "[email protected]" username = "username" password = "password"
mailserver = "smtp.gmail.com" port = 587
clientSocket = socket(AF_INET,SOCK_STREAM) clientSocket.connect((mailserver, port)) recv = clientSocket.recv(1024) print (recv) if recv[:3] != '220': print ("220 reply not received from server.")
heloCommand = 'HELO Alice\r\n' clientSocket.send(heloCommand) recv1 = clientSocket.recv(1024) print (recv1) if recv1[:3] != '250': print ("250 reply not received from server.")
ssl_clientSocket = socket.ssl(clientSocket)
mailFromCommand = 'MAIL FROM: ' + sender + '\r\n' ssl_clientSocket.write(mailFromCommand) recv2 = ssl_clientSocket.read(1024) print recv2 if recv2[:3] != '250': print '250 reply not received from server.'
rcptToCommand = 'RCPT TO: ' + recipient + '\r\n' ssl_clientSocket.write(rcptToCommand) recv3 = ssl_clientSocket.read(1024) print (recv3) if recv3[:3] != '250': print ("250 reply not received from server.")
dataCommand = 'DATA\r\n' ssl_clientSocket.write(dataCommand) recv4 = ssl_clientSocket.read(1024) print (recv4) if recv4[:3] != '354': print ("354 reply not received from server.")
ssl_clientSocket.write(msg)
ssl_clientSocket.write(endmsg) recv5 = ssl_clientSocket.read(1024) print (recv5) if recv5[:3] != '250': print ("250 reply not received from server.")
quitCommand = 'QUIT\r\n' ssl_clientSocket.write(quitCommand) recv6 = ssl_clientSocket.read(1024) print (recv6) if recv6[:3] != '221': print ("221 reply not received from server.")