我目前正在 Flex 中构建一个应用程序,该应用程序利用SMTP Mailer在满足特定条件时自动向用户发送电子邮件。应用程序每 30 秒检查一次此条件。基于从数据库表返回的新记录满足条件。
问题如下:
当条件首次满足时,电子邮件将毫无问题地传递给用户。
第二次满足条件时,邮件未送达。在 smtp 日志中,传递尝试似乎挂断在以下行:
354 Start mail input; end with <CRLF>.<CRLF>
smtp 日志中没有错误代码,但我确实跟踪了 SMTP Mailer 类中的以下事件:
[Event type="mailError" bubbles=false cancelable=false eventPhase=2]
当第三次满足条件时,上一次满足条件时未发送的电子邮件现在与此实例的电子邮件一起发送。
然后,此模式会重复自身,下一封电子邮件不会发送,然后当再次满足条件时会同时发送两封电子邮件。
正在使用的 smtp 服务器是内部网络上的 Windows 2003。电子邮件正在发送到托管在此内部网络上的 Exchange 服务器上的 Outlook 帐户。
这是创建 SMTPMailer 对象的操作脚本代码:
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);
}
以下是创建电子邮件正文并调用方法发送电子邮件的代码:
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() + " " + event.xml.@municipality.toString() + "</TD><TD>" + event.xml.@type.toString() + "</TD><TD>" + event.xml.@comment.toString() + "</TD><TD>" + event.xml.attribute("update-time").toXMLString() + "</TD></TR>";
}
testStr = testStr + "</TABLE></body></html>";
testMail.flush();
testMail.sendHTMLMail("r@ec.ca","w@ec.ca","Event Notification",testStr);
}
在最终发送之前,真的不确定挂断的电子邮件存储在哪里....
任何有关如何开始解决此问题的建议将不胜感激。