Emails sent using Flex app are delayed

Posted by user363825 on Stack Overflow See other posts from Stack Overflow or by user363825
Published on 2010-06-10T18:46:25Z Indexed on 2010/06/10 18:52 UTC
Read the original article Hit count: 275

I'm currently building an application in Flex that utilizes SMTP Mailer to automatically send out emails to the user when a particular condition is satisfied. The application checks this condition every 30 seconds. The condition is satisfied based on new records being returned from a database table.

The problem is as follows:

When the condition is first satisfied, the email is delivered to the user with no issues.

The second time the condition is satisfied, the email is not delivered. In the smtp logs, the delivery attempt appears to get hung up on the following line:

354 Start mail input; end with <CRLF>.<CRLF>

No error codes are present in the smtp logs, but I do trace the following event from the SMTP Mailer class:

[Event type="mailError" bubbles=false cancelable=false eventPhase=2]

When the condition is satisfied a third time, the email that was not delivered when the condition was satisfied the previous time is now delivered, along with the email for this instance.

This pattern then repeats itself, with the next email not being sent followed by two emails being sent simulatneously when the condition is met again.

The smtp server being used is Windows 2003, on an internal network. The email is being sent to an outlook account hosted on an exchange server that is also on this internal network.

Here is the actionscript code that creates the SMTPMailer object:

public var testMail:SMTPMailer = null;

public function alertNotify()
{   
Security.loadPolicyFile("crossdomain.xml"); 
this.testMail = new SMTPMailer("myserver.ec.local",25); 
this.testMail.addEventListener(SMTPEvent.MAIL_SENT, onEmailEvent);
this.testMail.addEventListener(SMTPEvent.MAIL_ERROR, onEmailError);
this.testMail.addEventListener(SMTPEvent.DISCONNECTED, onEmailConn);
this.testMail.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onEmailError);
}

Here is the code that creates the email body and calls the method to send the email:

public function alertUser(emailAC:ArrayCollection):void {

trace ("In alertUser() before send, testMail.connected = " + testMail.connected.toString()); var testStr:String = " Key Location Event Type Comment Update Time "; for each (var event:rEntity in emailAC) { testStr = testStr + "" + event.key.toString() + "" + event.xml.address.toString() + " " + [email protected]() + "" + [email protected]() + "" + [email protected]() + "" + event.xml.attribute("update-time").toXMLString() + ""; } testStr = testStr + ""; testMail.flush(); testMail.sendHTMLMail("[email protected]","[email protected]","Event Notification",testStr);

}

Really not sure where the email that gets hung up is being stored until it is finally sent....

Any suggestions as to how to begin to remedy this issue would be much appreciated.

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3