02-13-2012 10:21 AM
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 mail.smtp.host property. Unfortunately, not all emails are sent. Here's an example situation:
Given addresses: paul.baker@gmail.com, hank.newman@abc.com
I've tried to set SMTP server in java code like this:
if (email.endsWith("abc.com")) {
smtpHost = "abc.com";
} 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.
02-18-2012 10:49 PM
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 "jndi.java.mail").
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.
02-13-2012 12:06 PM
You should point mail.smtp.host 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.
02-18-2012 10:49 PM
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 "jndi.java.mail").
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.
02-20-2012 05:38 AM
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>
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.