Problem with capturing smtp email server return codes via socket

Admins can learn about SMTP errors and non-delivery reports (also known as NDRs or bounce messages) that are generated in Exchange Online.

Problem with capturing smtp email server return codes via socket

I have written a (cutdown) version of a simple smtp mail send program.
All works fine (in this cutdown version and the more complex version).

However, the email server returns a number of messages as the mail is sent.
The ProgressEvent.SOCKET_DATA (handleNewData function) does not seem to capture all the email return messages
(in particular I want to capture the
250 2.0.0 Ok: queued as XYZ
message to confirm the message was sent.

Anyone know why all the messages are not captured by the handleNewData and how I can correct this?

Thanks in advance.

My code is written in Adobe Air 2.5

My trace output is as follows:

Connecting to the mail server, example.com:25  
     Response is: 220 example.com ESMTP Postfix  
     Response is: 250 example.com  
     Response is: 250 2.1.0 Ok  
250 2.1.5 Ok  
354 End data with <CR><LF>.<CR><LF>  
250 2.0.0 Ok: queued as 2C0264F5FF  
221 2.0.0 Bye  

My code follows:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   creationComplete="Smtp()">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<s:Button label="Send Email" x="200" y="200" click="mail()"> </s:Button>

<fx:Script>
    <![CDATA[

            import flash.net.Socket;
            import flash.profiler.showRedrawRegions;
            import flash.utils.ByteArray;

            import mx.core.mx_internal;
            import mx.utils.ObjectUtil;

            private var socket:Socket;
            private var serverURL:String;
            private var serverPort:int = 25;
            private var serverResponse:ByteArray = new ByteArray();
            public var sendData:Array = new Array();
            public var dataStr:String;                  


            public function Smtp():void 
            {
                this.serverURL = "example.com";
                this.serverPort = 25;
                socket = new Socket();










Sorry chaps/chapettes,

the socket is indeed receiving all the server responses:-)

It's simply that near the part where the queued message is returned, the socket receives several lines at once.

Oh, well, hope the code was of some use to somebody.


Click Here to Visit

What's Your Reaction?

like
0
dislike
0
love
0
funny
0
angry
0
sad
0
wow
0