Closed petromir closed 9 years ago
Sure!!
Can you please send me your code, just want to see how did you use it; so we can model the interface in the best way?
This how I my code looks like:
SmtpSslServer smtpServer = SmtpSslServer.create("xxx", 587)
.authenticateWith("xxx", "xxx")
.property("mail.smtp.socketFactory.class", "");
According to this post http://stackoverflow.com/a/414396, mail.smtp.socketFactory.class
shouldn't be present, and I'm not sure whether you should remove it at all or just set it to empty string.
I see it something like this:
SmtpSslServer smtpServer = SmtpSslServer.create("xxx", 587)
.authenticateWith("xxx", "xxx").
.startTlsRequired(true) // Similar to Apache Commons Email
.setDebug(true) // Should set 'mail.debug' - very useful for debugging.
Just a question - would you mind if TLS is set on by default? Just to keep backward compatibility, so you can use either:
startTlsRequired(false)
orplaintextOverTLS(true)
which one would be better in your opinion? Maybe the first one?
btw, just added debug
flag ;)
After thorough reading of Apache Commons Email sources and Java Mail settings (https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html) I think that it would be nice if you think about the following stuff:
startTlsRequired()
- sets mail.smtp.starttls.required
which according to Java Mail API means:
If true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, or the command fails, the connect method will fail. Defaults to false.I saw that Jodd Mail sets implicitly mail.smtp.starttls.enable
to true, and I'm not sure if it's good idea do expose only one of the STARTTLS settings.
plaintextOverTLS
can do the actual job by just resetting the default value of mail.smtp.socketFactory.class
to empty string (Jodd Mail uses javax.net.ssl.SSLSocketFactory
for its SmtpSslServer
)Sorry if I have misled you with my previous code proposal.
No problem, I will just add few of these methods... stay tuned, will send some code soon.
Did exactly how you proposed it :) Thank you for your time, I really appreciate!
Thanks for the fast response. I will be glad if you suggest me some nice Java mock mail server :)
I am on the same search as well ;) For now, I think I will use GreenMail in my tests; but havent tried it yet.
Thanks.It looks promising. I will try it along with its the competitors.
It's very difficult to understand how to configure
SmtpSslServer
in order to useSTARTTLS
. I managed to find a way by setting the following propertymail.smtp.socketFactory.class
to empty string. Мoreover everything else throws exceptions. (e.g.javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection
). Default value of this property isjavax.net.ssl.SSLSocketFactory
.It would be great if you implement more convenient way for setting
STARTTLS
properly and add documentation for it.