Can someone help me out? I'm supposed to turn in a project and I cannot figure out how to code it correctly.

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"

Choose a mail server (e.g. Google mail server) and call it mailserver

mailserver = "smtp.gmail.com" port = 587

create socket called clientSocket and establish a TCP connection with mailserver

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.")

Send HELO command and print server response.

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.")

Encrypt the socket

ssl_clientSocket = socket.ssl(clientSocket)

Send MAIL FROM command and print server response.

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.'

Send RCPT TO command and print server response.

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.")

Send DATA command and print server response.

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.")

Send message data.

ssl_clientSocket.write(msg)

Message ends with a single period.

ssl_clientSocket.write(endmsg) recv5 = ssl_clientSocket.read(1024) print (recv5) if recv5[:3] != '250': print ("250 reply not received from server.")

Send QUIT command and get server response.

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.")

/r/learnpython Thread