-
15. Re: JavaMail support on AS7
zenzei2k Nov 30, 2011 10:53 AM (in response to ctomc)Hi tomaz! Thanks for your clarification.
About the starttls, I think i need it cause I'm using gmail smtp and it requires that property to be set (at least on jboss4). I didn't need it so quickly cause I'm testing Jboss 7 right now, but I'll glad to test the fix when you prepare it.
Thanks in advance!
-
16. Re: JavaMail support on AS7
alfred.graber Dec 5, 2011 3:24 AM (in response to ctomc)Hi Tomaz
unfortunately it seems, that your implementation does not work yet 100%
logging:
Setting the attribute "debug" has no effect.
The reason is that the Properties-object used to create the new Session instance contains the property "mail.debug" but as a Boolean.
This is wrong: Properties must only contain String values, otherwise the method "getProperty" will return null (everything except Strings is just ignored).
I have seen, that you use the "put" method to set the properties - you should not do this, because the "put" method is inherited from Hashtable and allowes to set any object as value - use the "setProperty" method instead
smtp-auth:
it seems that corresponding property "mail.smtp.auth" is not set (I did not find it) - or maybe its the same problem as above (Boolean istead of String) - so there is no authentication performed before sending the mail, which leads to exception if the mailserver requires authentication.
Cheers
Alfred
-
17. Re: JavaMail support on AS7
ctomc Dec 5, 2011 11:41 AM (in response to alfred.graber)Hi guys,
@Alfred tnx for info, it helped alot.
I have fixed the problem of logging not working and improved it furher so it also sets protocol to debug not just general java mail stuff.
Implementation now correctly honors authentification and also correctly handles SSL encripted connections.
I have tested with gmail SSL smtp and it worked correctly, but with TLS(different port) I get strage exception that I will have to digg in deeper.
config with which I have tested:
<mail-session jndi-name="java:/Mail" debug="true">
<smtp-server ssl="true" outbound-socket-binding-ref="mail-smtp">
<login name="user dot name at gmail dot com" password="password"/>
</smtp-server>
</mail-session>
...
...
<outbound-socket-binding name="mail-smtp">
<remote-destination host="smtp.gmail.com" port="465"/> <--! please note 465 is SSL that works, 587 is TLS and currently does not work -->
</outbound-socket-binding>
fixes are currently present in my work of as7 https://github.com/ctomc/jboss-as/tree/mail2
If possible can you test the fixes if they work for your scenarios.
Tnx,
Tomaz
-
18. Re: JavaMail support on AS7
whutchinson Dec 12, 2011 5:28 AM (in response to gastaldi)Hi,
Was not able to get authentication to work after trying with the latest hudson build. Perhaps you have it resolved already, but I had to modify MailSessionService with the changes below.
Apologies for the lack of detail, this was my last obstacle for the upgrade from version 5 to 7.1 and took a little while to figure out the issue.
<mail-session jndi-name="java:/Mail" debug="true"> <smtp-server outbound-socket-binding-ref="mail-smtp-pbrfid"> <login name="xxxxxxx" password="xxxxx"/> </smtp-server> </mail-session> <outbound-socket-binding name="mail-smtp-pbrfid"> <remote-destination host="smtpout.secureserver.net" port="80"/> </outbound-socket-binding> public Session getValue() throws IllegalStateException, IllegalArgumentException { Credentials credentials = config.getSmtpServer().getCredentials(); Authenticator authenticator = null; if(credentials != null) { authenticator = new Authenticator(credentials.getUsername(), credentials.getPassword()); } final Session session = Session.getInstance(props, authenticator); setAuthentication(session); return session; } private class Authenticator extends javax.mail.Authenticator { private PasswordAuthentication authentication; public Authenticator(String username, String password) { authentication = new PasswordAuthentication(username, password); } protected PasswordAuthentication getPasswordAuthentication() { return authentication; } } -
19. Re: JavaMail support on AS7
alfred.graber Dec 12, 2011 3:17 AM (in response to whutchinson)Hi Walter
I do not think, Tomaz has put it in the head - so I suppose it is not in the hudson build yet...
So maybe ask him to do so
Alfred
-
20. Re: JavaMail support on AS7
ctomc Dec 12, 2011 6:07 AM (in response to alfred.graber)Hi guys,
yes it is not in head/upstream yet, as I am working on management aspect of subsystem to make it manageable trough admin console...
in the mean time you can use my fixes by putting attached two files in JBOSS_HOME/modules/org/jboss/as/mail/main and delete all files previously there.
The code will be in upstream before CR1 is released...
cheers,
tomaz
-
module.xml 1.8 KB
-
21. Re: JavaMail support on AS7
whutchinson Dec 15, 2011 9:50 PM (in response to gastaldi)The files you provided works perfectly.
Thanks,
Hutch
-
22. Re: JavaMail support on AS7
blabno Jan 3, 2012 8:57 AM (in response to whutchinson)Has this made into 7.1.0.CR1?
-
23. Re: JavaMail support on AS7
ctomc Jan 3, 2012 3:29 PM (in response to blabno)Unfortunately no, I have missed the deadline for few hours.
It is in upstream now, so you can use nightly build or manually apply patch from this thread.
-
24. Re: JavaMail support on AS7
chufaca Feb 10, 2012 7:28 AM (in response to ctomc)I want to ask something related to the topic here:
I'm using 7.1.0.CR1b, and the configuration of the JavaMail doesn't work properly, I'm receiving a "09:20:55,156 ERROR [stderr] (MSC service thread 1-4) javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]".
The java code works fine in JBoss 5, but not with this version.
Here I give you my config file if needed:
<subsystem xmlns="urn:jboss:domain:mail:1.0">
<mail-session jndi-name="java:/Mail" debug="true">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
</subsystem>
And in the socket-binding-group:
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
I appreciate any help. Thanks in advance
Facu
-
25. Re: JavaMail support on AS7
ctomc Feb 10, 2012 8:15 AM (in response to chufaca)Hi,
this looks like problem with connecting to localhost port 25,
can you please try with latest nightly build https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/ (this is really close to 7.1.0.Final)
if it still does not work, post while stack trace.
otherwise please create new thread as it is different problem that original thread.
cheers,
tomaz
-
26. Re: JavaMail support on AS7
user1919 Jun 20, 2012 8:13 AM (in response to ctomc)Hello Tomaz,
I am trying to connect with JBoss 7.1.1 to an own configured server (postfix) that uses TLS. No success, with your patch files or some others. I get some strange authentication error. I believe my server to be properly configured, since I tried it with Thunderbird, and the option starttls and it works fine. Do you have any idea/suggestion on what to do?
-
27. Re: JavaMail support on AS7
ctomc Jun 20, 2012 8:26 AM (in response to user1919)Hi Ignacio,
I am not sure connecting to TLS servers works as i don't have any way of testing it... The code for doing that is in place and it "should" work...
Can you create a new thread about this as this is issue just with TLS, and plase post you configuration (ofcourse mask un/pw)
--
tomaz