JBoss AS 7.1.0 Mail

Since version 7.1.0 JBoss AS includes a mail subsystem by default and it seems to work with a local postfix installation out of the box. Here is a simple mailer bean:

import javax.annotation.security.RolesAllowed;
import javax.enterprise.inject.Model;
import javax.inject.Inject;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import org.jboss.logging.Logger;

 * @author manuel
public class TestMailController {

	private Session session;

	private Logger log;

	public void sendMail() {
		log.debug("sending mail");
		final Message msg = new MimeMessage(session);
		try {

			final InternetAddress addressFrom = new InternetAddress(
			log.debug("set from");

			final InternetAddress[] recipients = new InternetAddress[] {
                             new InternetAddress("manuel@localhost") };
			msg.setRecipients(Message.RecipientType.TO, recipients);
			log.debug("set recipients");

			msg.addHeader("CustomHeader", "some value");
			log.debug("added custom header");

			log.debug("set subject");

			msg.setContent("my message", "text/plain");
			log.debug("set message");

			log.debug("message sent");
		} catch (final MessagingException exc) {