Question

im using a telnetlib in python to connect to a simple mail server and send out an email; everything works fine until the very end after i enter the DATA command, you submit the body of your message and in order to submit the email in the server's queue, you need to type a period "." on a new line by itself so my end transaction snippet looks like so

self.tnet.write("\n.\n")
self.tnet.read_until("250")

where self.tnet is my telnet session var and read_until waits for the 250 Ok response saying the email has been sent to the queue of the email server and on its way for delivery; however, i do not get that 250 Ok response back and the connection times out to my 10sec timeout flag and no email is received in my inbox... any ideas? ive also tried

self.tnet.write(raw_input()+"\n")

and ive also tried grabbing the raw socket

self.sock=self.tnet.get_socket()
self.sock.send(".\n")
print self.sock.recv(1024)

no response... :/ ive also tried the return carriage "\r" in combination with "\n" and on it own to no avail

any ideas?

thank you, ~george

Was it helpful?

Solution

you need the <CR><LF> newline-squence try:

self.tnet.write("\r\n.\r\n")

hope that helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top