1

我刚刚开始研究 ICEsoft。我有一个 ICEmobile 项目,我尝试在其中实现向用户发送通知。我使用 Tomcat 7、ICEmobile 1.1、ICEfaces 3,我的 IDE 是 Eclipse Juno 4.2。以下是一些用于呈现消息的代码片段:

    /** 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.端口:465

smtp.user:myaccount@gmail.com

smtp.密码...

smtp.security:SSL

smtp.verify-server-certificate - false

我正在 ICEmobile Container (4.1, 16 + Google APIs) 中的 Android 模拟器上测试所有这些。在那里,我取消选中了 C2DM 通知属性,并在“电子邮件通知”中输入了我的电子邮件地址。

使用该代码,我无法发送电子邮件。我收到这样的错误:

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,但不知道如何正确配置 - 也许提示就在其中?

在此先感谢,伊琳娜

4

1 回答 1

0

我通过更新我的 mail.jar 解决了这个问题。我的太旧了。

于 2012-10-15T19:53:42.507 回答