Jboss4中使用配置发送邮件

利用jmail 发邮件就不赘述,本文主要说下利用jboss本身的服务:mail-service。

配置文档位置 {jboss4.2_home}/server/default/deploy/mail-service.xml,原配置如下;

<mbean code="org.jboss.mail.MailService"
         name="jboss:service=Mail">
    <attribute name="JNDIName">java:/Mail</attribute>
    <attribute name="User">nobody</attribute>
    <attribute name="Password">password</attribute>
    <attribute name="Configuration">
       <!-- Test -->
       <configuration>
          <!-- Change to your mail server prototocol -->
          <property name="mail.store.protocol" value="pop3"/>
          <property name="mail.transport.protocol" value="smtp"/>
          <!-- Change to the user who will receive mail -->
          <property name="mail.user" value="nobody"/>
          <!-- Change to the mail server -->
          <property name="mail.pop3.host" value="pop3.nosuchhost.nosuchdomain.com"/>
          <!-- Change to the SMTP gateway server -->
          <property name="mail.smtp.host" value="smtp.nosuchhost.nosuchdomain.com"/>
          <!-- Change to the address mail will be from -->
          <property name="mail.from" value="nobody@nosuchhost.nosuchdomain.com"/>
          <!-- Enable debugging output from the javamail classes -->
          <property name="mail.debug" value="false"/>
       </configuration>
    </attribute>

修改:

<mbean code="org.jboss.mail.MailService"
         name="jboss:service=Mail">
    <attribute name="JNDIName">java:/tourMail</attribute><!-- JNDI name 具体看相关资料 名 -->
    <attribute name="User">user</attribute><!-- 邮箱用户名 -->
    <attribute name="Password">******</attribute><!-- 邮箱密码 -->
    <attribute name="Configuration">
       <!-- Test -->
       <configuration>
         <!-- smtp check -->
         <property name="mail.smtp.auth" value="true"/><!-- 这个很重要,如果邮箱服务器要smtp 验证一定要加该属性才能通过验证 -->
          <!-- Change to your mail server prototocol -->
          <property name="mail.store.protocol" value="pop3"/><!-- 接受协议 默认pop3-->
          <property name="mail.transport.protocol" value="smtp"/><!-- 传输协议 默认smtp -->
          <!-- Change to the user who will receive mail -->
          <property name="mail.user" value="Admin"/>
          <!-- Change to the mail server -->
          <property name="mail.pop3.host" value="pop3.126.com"/><!-- pop3 服务器 -->
          <!-- Change to the SMTP gateway server -->
          <property name="mail.smtp.host" value="smtp.126.com"/><!-- smtp 服务器 -->
          <!-- Change to the address mail will be from -->
          <property name="mail.from" value="email@126.com"/><!-- 邮箱地址 ,与上面的用户名一致 -->
          <!-- Enable debugging output from the javamail classes -->
          <property name="mail.debug" value="true"/><!-- 是否打印信息 -->
       </configuration>
    </attribute>
 </mbean>

posted @ 2012-11-23 11:26  IT_熊  阅读(302)  评论(0)    收藏  举报