JavaMail in Nuxeo

I have a problem with sending emails via JavaMail from Nuxeo. My customization contains with a new type that has its own layout. There is one field where I type email addresses. After submitting form, a proper event listener executes code which sends emails to given addresses (JavaMail). SMTP host is taken from property. Unfortunately, not all emails are sent. Here's an example situation:

Given addresses:,

  1. property is set to server2003 (which is localhost and has SMTP service configured with Windows Server 2003). Email is sent only to
  2. property is set to (which is the domain provided by web hosting company with SMTP service). Email is sent only to

I've tried to set SMTP server in java code like this:

if (email.endsWith("")) {
   smtpHost = "";
} else {
   smtpHost = "server2003";
sendMail(..., smtpHost, ...)

but Nuxeo seems to force SMTP host which is currently set in nuxeo.conf file. How can I make Nuxeo send these emails properly? I'm using Tomcat distribution. Please, let me know if more info is needed.

0 votes

2 answers



Are you using Nuxeo 5.5?

What does your method sendMail(…, smtpHost, …)? Do you rely on Nuxeo code for sending the mail or do you directly call JavaMail?

Nuxeo ends by calling javax.mail.Transport.send(Message) but depending on the way you call it, a properties file or a System property may be used, although in most cases, Nuxeo will likely get a javax.mail.Session created by Tomcat with parameters in conf/Catalina/localhost/nuxeo.xml (coming from nuxeo.conf) looking up for “java:comp/env/Mail” (or “java:/Mail”) in JNDI (the session name is setup by the property “”).

So, you should be able either to dynamically change some values, or to make Nuxeo sometimes use another javax.mail.Session than the default one configured with properties from nuxeo.conf.

1 votes

Thanks Julien, your reply was very helpful. I use JavaMail directly from my code. Finally, I found out that I was using default Session to send mail by calling <pre><code> Session session = Session.getDefaultInstance(properties, null);</code></pre> Now I can dynamically change SMTP host using <pre><code> Session session = Session.getInstance(properties);</code></pre>

You should point to your own smtp server and have rules in place to allow routing of mail (from your Nuxeo server) to external domains. The setup is different for each mail server but the concepts are the same.

2 votes