JBoss Community Archive (Read Only)

JBoss AS 7.1

Mail Subsystem

Mail subsystem XSD. (Shows empty page in some browsers - view the source.)


mail-session may contain:  ( smtp-server | imap-server | pop3-server )*
      @debug            Enables debuging of mail session
      @from               Sets mail.from attribute

*-server may contain:      login
      @ssl                                                  Enables use of ssl for this server configuration. Typically, used with an outbound socket with port 465.
      @tsl                                                   Enables use of tls for this server configuration.
      @outbound-socket-binding-ref     Reference to the outbound-socket-binding element in the socket-binding-group that should
                                                                 be used for configuring the client socket used to communicate with the mail server.

Example mail subsystem configuration:

     <subsystem xmlns="urn:jboss:domain:mail:1.0">
        <mail-session jndi-name="java:jboss/mail/Default">
            <smtp-server ssl="true" outbound-socket-binding-ref="smtp-example">
                <login name="foo@example.com" password="12345"/>
        <mail-session jndi-name="java:jboss/mail/RedHat">
            <smtp-server ssl="true" outbound-socket-binding-ref="smtp-seznam">
                <login name="bar@seznam.cz" password="12345"/>


<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <outbound-socket-binding name="smtp-example">
        <remote-destination host="smtp.example.com" port="465"/>
    <outbound-socket-binding name="smtp-seznam" source-port="0" fixed-source-port="false">
        <remote-destination host="smtp.seznam.cz" port="465"/>
public class MailSender {

    private Session mailSessionSeznam;

    private void sendMail(Session mailSessionSeznam, String mailFrom, String sMailTo, String sSubject, String sMailText) throws MessagingException {
       MimeMessage message = new MimeMessage( mailSessionSeznam );
       message.setFrom( new InternetAddress( mailFrom ) );
       message.setReplyTo( new Address\[\]{new InternetAddress( this.mailReplyTo )} );
       message.addRecipient( Message.RecipientType.TO, new InternetAddress( sMailTo ) );
       message.setHeader( "Content-Type", this.mailContentType + "; charset=\"" + this.mailEncoding + "\"");
       message.setSubject( sSubject );
       message.setText( sMailText );
       Transport.send( message );&nbsp;&nbsp;&nbsp;&nbsp; }// sendMail()


JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 13:22:05 UTC, last content change 2013-03-04 12:56:08 UTC.