2

I set up Dspace to send e-mail using my company's e-mail server, DSpace uses javax.mail to do this.

When I try send outside of my company's network the e-mail is sent successfully, but in the company's network the email is not sent.

Follows the shown error message:

Error: javax.mail.MessagingException: Exception reading response;
nested exception is: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

(1) There's no proxy on the way
(2) I tryed to send using gmail, but I've got same scenario
(3) The only related thread that I've found were solved with proxy settings, but because (1) that is not a solution (Java mail doesn't work in the company's network)
(4) The used door (587) is the same configured in Thunderbird which works great both inside and outside my company's network.

WHAT A MISTERY!!! O.O

If some one could help, that would be great!

Thanks a lot!

Lino
  • 95
  • 7
  • If you can send mail (and I suppose you can ...) with thunderbird, you should send be able to send mail with javamail **provided you use exactly same configuration**. Point to give attention : the mail server (!), the port, the security options (SSL socket, STARTTLS, authentication). – Serge Ballesta Dec 04 '14 at 13:50
  • @SergeBallesta I'm using the same configuration, as you suggested. And it is working outside company's network, but bringing to company's context the problem appears. If there was an wrong configuration the mail wouldn't be sent outside company too, right? Thanks for reply! – Lino Dec 04 '14 at 14:18
  • SMTP is a nice by complex protocol with many options in relaying. When you say it is working outside company's network, does is mean to addresses outside company or from a machine outside company's network ? Main question : where is the mail server you use : outside or inside company's network ? – Serge Ballesta Dec 04 '14 at 14:23
  • @SergeBallesta I'm running DSpace on a laptop so I'm refering to connect server on company's network or outside (my home). But the company's mail server is ever inside the comany's network, of course. – Lino Dec 04 '14 at 16:36
  • I suppose that the server has different configurations for what comes from the inside and from the outside. But it should not make a difference between javamail and thunderbird if the client configurations were the same. Don't you have an authentication in thunderbird (inside company's network) ? – Serge Ballesta Dec 04 '14 at 17:03
  • @SergeBallesta Thanks!!! I found a solution!! http://stackoverflow.com/a/20347799/4324194 - (non ssl properties are). Unfortunately I still not understand why this was working outside company's network. =( – Lino Dec 04 '14 at 17:26
  • I think you should post an self-answer to explain what happened for future reference. – Serge Ballesta Dec 04 '14 at 17:28

1 Answers1

0

I found an answer in another thread that guided me:

Javamail non ssl properties are:

Properties props = new Properties();
props.put("mail.smtp.user", "email@mydomain.com");
props.put("mail.smtp.password", "password");
props.put("mail.smtp.protocol", "smtp");
props.put("mail.smtp.host", "smtp.mydomain.com");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.starttls.enable","false");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.port", "25");
props.put("mail.smtp.socketFactory.class", "");
props.put("mail.smtp.socketFactory.fallback", "false");

The only property that I changed to DSpace start send email was mail.smtp.socketFactory.class="", before was "javax.net.ssl.SSLSocketFactory".

Unfortunately I still not understand why previous settings were working outside company's network, maybe some rule blocking ssl connections.

@SergeBallesta: Thanks for the help!

Community
  • 1
  • 1
Lino
  • 95
  • 7
  • You should really [get rid of ALL the socket factory properties](http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes), in all cases. – Bill Shannon Dec 05 '14 at 00:09
  • @BillShannon Hum, nice one! Thanks for the reference! – Lino Dec 07 '14 at 13:33