ghostils has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE: I figured it out. After a DATA client command I had to issue a 354 OK and then a 250 OK after "." is recieved on EOF. Hello, I have a what should have been a simple problem that is turning into a headache, and I'm not quite sure its my perl code that is causing it. I have a simple piece of perl code that uses the IO::Socket/Select to make a very simple SMTP select server. The idea is that I send email from my phone to my domain and the SMS passes through tmobiles gateway, and I get the email data, strip the headers, and operate on the SMS message data to perform simple or not so simple things, so its basically an SMS->Gateway->SMTP shell. The problem it seems is that SMS email gateway's don't seem to send SMTP in vanilla format. I have a session dump from my comcast account, and from a tmobile SMS->Email gateway. They are vastly different. I can recieve the entire message from header to end of data, and all the SMTP commands inbetween from comcast, but Tmobile it gets to the DATA command and sends me a RSET, and promptly sends a QUIT message to my server and disconnects, I don't ever see any message data just protocol commands. My server is very simple and only supports a few commands otherwise just sends 250 OK's back to what ever client connects.
#-SMS Gateway over SMTP e-mail protocol: #-(c)ode by Brodie Ponas #- #- User Socket, and Select Packages: use IO::Socket; use IO::Select; use Socket; use Net::SMTP; #-first arg is ip address #-2nd arg is port: foreach $arg (@ARGV) { $_ = $arg; #-Address: if (m/\-addr\:(.+)/i) {$address = $1;} #-Port: if (m/\-port\:(.+)/i) {$port = $1;} } #-Setup sockets: $ConnectionSocket = new IO::Socket::INET(Listen => 1, LocalHost => $ad +dress ,LocalPort => $port); $SelectHandle = new IO::Select( $ConnectionSocket ); print "iLs SMS SMTP Gateway Listening...\r\n"; print "LocalAddr: $address\r\n"; print "LocalPort: $port\r\n"; $isRecvData = 0; while(@Connections = $SelectHandle->can_read) { foreach $SocketHandle (@Connections) { #-Incomming Connection: if($SocketHandle == $ConnectionSocket) { # Create a new socket $NewClient = $ConnectionSocket->accept; $SelectHandle->add($NewClient); print "Client Connect ", $NewClient->peerhost, ":", $NewCl +ient->peerport, "\r\n"; #-Tell mail client we are ready: print $NewClient "220\r\n"; } #-Established Connections: else { # Process socket data: #-We are recv'n the actual SMTP DATA field now, we don' +t want to send anythign back to the client: if ($isRecvData == 1) { $Data = <$SocketHandle>; $_ = $Data; #-End of Data: reset flag: send OK: if (m/\./i) { print $SocketHandle "250\r\n"; $isRecvData = 0; } print "$Data\r\n"; next; } #-Recv Stream: $Data = <$SocketHandle>; $_ = $Data; if (m/QUIT/i) { print $SocketHandle "221\r\n"; $SelectHandle->remove($SocketHandle); $SocketHandle->close; } #-Start of DATA: elsif(m/DATA/i) { print $SocketHandle "250\r\n"; $isRecvData = 1; } #-Any other command we just give them an OK we just car +e about the data messaage and sender address for now: else {print $SocketHandle "250\r\n";} print "$Data"; } $Data = ""; } }
Here are the session dumps with my various personal info changed. TMobile:
------------------------------------ EHLO mailx05.tmomail.net MAIL From:<1231231234@tmomail.net> RCPT To:<bp@myserver.org> DATA RSET QUIT ------------------------------------
Comcast Session
------------------------------------ EHLO alnrmhc13.comcast.net MAIL FROM:<bponas@comcast.net> RCPT TO:<bponas@myserver.org> DATA Received: from myserver (c-67-168-213-7.hsd1.wa.comcast.net[67.168.213 +.7]) by comcast.net (alnrmhc13) with SMTP id <20070509184137b1300do65ie>; Wed, 9 May 2007 18:41:37 +00 +00 From: "bponas" <bponas@comcast.net> To: <bponas@myserver.org> Subject: RE: COMCAST PLAINTEST SEND FROM SERVER TEST Date: Wed, 9 May 2007 11:38:48 -0700 Message-ID: <NEEMKLLCMPCCPEPDMOCFIEKACCAA.bponas@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 Importance: Normal In-Reply-To: <NEEMKLLCMPCCPEPDMOCFEEKACCAA.bponas@comcast.net> TADAH DOES MY STUFF WORK? . QUIT -------------------------------------
Anyone have a better grasp of SMS->Email SMTP that could chime in here? Thanks, -Brodie