Saturday, May 2, 2009

Setting up GMail SMTP through JBoss mail-service.xml

I may have been unusually unfortunate in this respect, but based on the number of postings that reported problems trying to configure email settings on JBoss against the GMail SMTP server, I thought I'd just publish the following configuration as a confirmed successful one - simply edit your mail-service.xml under JBoss (tested against version 4.2.2.GA) to make it so:




<?xml version="1.0"?>
<server>
<mbean code="org.jboss.mail.MailService" name="jboss:service=MailSession">
<attribute name="JNDIName">mail/MailSession</attribute>
<attribute name="User">youraddress@gmail.com</attribute>
<attribute name="Password">yourpassword</attribute>
<attribute name="Configuration">
<configuration>
<property name="mail.transport.protocol" value="smtp"/>
<property name="mail.smtp.user" value="youraddress@gmail.com"/>
<property name="mail.smtp.password" value="yourpassword"/>
<property name="mail.smtp.starttls.enable" value="true"/>
<property name="mail.smtp.auth" value="true"/>
<property name="mail.smtp.host" value="smtp.gmail.com"/>
<property name="mail.smtp.port" value="465" />
<property name="mail.from"
value="recipientaddress@someserver.com"/>
<property name="mail.smtp.socketFactory.class"
value="javax.net.ssl.SSLSocketFactory" />
<property name="mail.smtp.socketFactory.port" value="465" />
</configuration>
</attribute>
</mbean>
</server>

No comments: