【发布时间】:2012-10-03 00:32:47
【问题描述】:
我刚刚开始研究 ICEsoft。我有一个 ICEmobile 项目,我尝试在其中实现向用户发送通知。我使用 Tomcat 7、ICEmobile 1.1、ICEfaces 3,我的 IDE 是 Eclipse Juno 4.2。 下面是一些渲染消息的代码sn-ps:
/** from NotificationBean class (ApplicationScoped) **/
// render group is the current session id.
public String renderGroup = "renderGroup";
public NotificationBean() {
PushRenderer.addCurrentSession(renderGroup);
}
/** from NotificationController class (ViewScoped) **/
NotificationBean notifBean = (NotificationBean)FacesUtils.getManagedBean("notificationBean");
public void sendPriorityPushMessage(ActionEvent event) {
final PushMessage myMessage = new PushMessage(notifBean.getSubject(), notifBean.getMessage());
final PortableRenderer portable = PushRenderer.getPortableRenderer();
...
portable.render(notifBean.renderGroup, myMessage);
...
}
我在 web.xml 中配置了 SMTP 设置:
smtp.host: smtp.gmail.com
smtp.from: myaccount@gmail.com
smtp.port: 465
smtp.user:myaccount@gmail.com
smtp.password ...
smtp.security: SSL
smtp.verify-server-certificate - false
我正在 Android 模拟器上的 ICEmobile Container(4.1、16 + Google API)中测试所有这些。在那里我取消选中 C2DM Notify 属性并在“电子邮件通知”中输入我的电子邮件地址。
使用该代码我无法发送电子邮件。我收到这样的错误:
WARNING: Failed to send email message.
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
at javax.mail.Service.connect(Service.java:295)
at org.icepush.EmailNotificationProvider$SendMessage.run(EmailNotificationProvider.java:138)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:507)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
我错过了什么吗?我尝试配置我的 Tomcat,但不知道如何正确配置 - 也许提示就在其中?
提前致谢, 伊琳娜
【问题讨论】:
标签: android-emulator notifications smtp gmail icepush