我正在使用jboss 7.1.1并希望使用JavaMail发送电子邮件。我尝试了以下配置但是收到错误。有人用Jboss 7.1.1配置了gmail吗?
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
<socket-binding name="ajp" port="8009"/>
<socket-binding name="http" port="8080"/>
<socket-binding name="https" port="8443"/>
<socket-binding name="jacorb" interface="unsecure" port="3528"/>
<socket-binding name="jacorb-ssl" interface="unsecure" port="3529"/>
<socket-binding name="messaging" port="5445"/>
<socket-binding name="messaging-throughput" port="5455"/>
<socket-binding name="osgi-http" interface="management" port="8090"/>
<socket-binding name="remoting" port="4447"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
<outbound-socket-binding name="mail-smtp-gmail">
<remote-destination host="smtp.googlemail.com" port="587"/>
</outbound-socket-binding>
</socket-binding-group>
这是邮件配置
<subsystem xmlns="urn:jboss:domain:mail:1.0">
<mail-session jndi-name="java:jboss/mail/Default">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
<mail-session jndi-name="java:jboss/mail/TestGmail">
<smtp-server outbound-socket-binding-ref="mail-smtp-gmail">
<login name=mymail@gmail.com" password="mypass"/>
</smtp-server>
</mail-session>
</subsystem>
答案 0 :(得分:7)
使用JBoss 7.1发送电子邮件的有效配置:
[1]在章节子系统中:mail - &gt;
<subsystem xmlns="urn:jboss:domain:mail:1.0">
<mail-session jndi-name="java:jboss/mail/SampleMS_With_GmailUser">
<smtp-server ssl="true" outbound-socket-binding-ref="mail-gmail-smtp">
<login name="myemailingmail@gmail.com" password="myPasswordInGmail"/>
</smtp-server>
</mail-session>
</subsystem>
注意:
该名称必须包含完整的电子邮件地址,并附带@ gmail.com
必须设置smtp-server标志ssl =“true”
[2]在socket-binding-group - &gt;
部分<socket-binding-group ....>
<outbound-socket-binding name="mail-gmail-smtp">
<remote-destination host="smtp.gmail.com" port="465"/>
</outbound-socket-binding>
</socket-binding-group>
多数民众赞成。然后你可以使用它,例如在servlet中:
@WebServlet(urlPatterns = "/servlets/public/SendEmailTestServlet")
public class SendEmailTestServlet extends HttpServlet {
@Resource(mappedName = "java:jboss/mail/SampleMS_With_GmailUser")
javax.mail.Session mailSession;
// use of mailSession
}