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
{
var testStr:String = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body><TABLE border=\"1\"><TR><TH><b> Key </b></TH><TH><b> Location </b></TH><TH><b> Event Type </b></TH><TH><b> Comment </b></TH><TH><b> Update Time </b></TH></TR>";
for each (var event:rEntity in emailAC) {
testStr = testStr + "<TR><TD>" + event.key.toString() + "</TD><TD>" + event.xml.address.toString() + " " + [email protected]() + "</TD><TD>" + [email protected]() + "</TD><TD>" + [email protected]() + "</TD><TD>" + event.xml.attribute("update-time").toXMLString() + "</TD></TR>";
}
testStr = testStr + "</TABLE></body></html>";
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.