リソースを webapp context.xml に追加する例に従いました
<Resource auth="Container" mail.smtp.host="localhost"
name="containeremail" type="javax.mail.Session" />
そして、私が持っているweb.xmlには:
<resource-ref>
<description>Container Email resource</description>
<res-ref-name>containeremail</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
次に、Javamail を使用して次のようなメールを送信します。
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
mailSession=(Session)envCtx.lookup("containeremail");
mailSession.setDebug(true);
Transport.send(message);
これは私の開発環境ではうまく機能します。
ただし、本番環境の CENTOS ボックスにデプロイすると、次の例外が発生します。
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 365;
ネストされた例外は次のとおりです: java.net.ConnectException: 接続が拒否されました
Postfix が両方のマシンにインストールされ、実行されています。context.xml でポートを 25 に指定してみました:
mail.smtp.port="25"
しかし、これでも、ポート365を参照する上記の例外がまだあります????
何が間違っているかについてのアイデアはありますか?
ありがとう
スプノグ