Mail plugin difference in Servoy 6.0.x?

Hi,
has there been a change in how the Mail plugin work in Servoy 6.0 than in 5.2.x?
I have a solution I am migrating from 5 to 6 (I started this before 7 was out and also they didn’t want me going to 6.1…) and emailing that was working on Servoy 5 using the standard Servoy mail plugin now isn’t working…
The error in the log is

javax.mail.MessagingException: Could not connect to SMTP host: send.nhs.net, port: 587; 
     nested exception is: 
     javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? 
     at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934) 
     at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638) 
     at javax.mail.Service.connect(Service.java:317)

All the mail plugin parameters are the same in the Admin/Server Plugins page and I am using the extra property

mail.smtp.starttls.enable=true
```in my code.

Server Network Settings are
SocketFactory.tunnelConnectionMode = 2WaySocket
SocketFactory.compress: = true
SocketFactory.useSSL: = false (which is what other servers are set to & I thought this is only for communication between Servoy Server & Servoy Client)
SocketFactory.tunnelUseSSLForHttp: = false

Looking around the 'net this is an issue, but about the only thing that I could find that some used to solve it was to to do this

System.setProperty(“sun.security.ssl.allowUnsafeRenegotiation”, true);


as some kind of Java property, but I'm not sure how to set this from Servoy. The implication is that Servoy is trying to talk to what should be an HTTPS port, but is using HTTP...

I found the (new) page for the Java mail smtp properties at 
https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html
but wasn't sure if there was something extra from there I needed to set.
Java on Server is set to 'Direct Connection', I have cleared caches, restarted etc., but still no luck.
Other production servers are working fine (but running Servoy 5).

It is essential that the mail stuff uses SLL/TLS as the data being sent is Medical info (patient data etc.)

I hope someone can help <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /> 

Thanks

Rafi

Hi Rafi,

the only thing I bumped into using 6.0 was a conflict in the mail.jar between the default mail plugin and the MailPro plugin.
As I didn’t use the MailPro plugin in that project it was solved easily…

Can’t remember seeing things you posted.

Hi Marc,

mboegem:
Hi Rafi,
the only thing I bumped into using 6.0 was a conflict in the mail.jar between the default mail plugin and the MailPro plugin.
As I didn’t use the MailPro plugin in that project it was solved easily…
Can’t remember seeing things you posted.

Thanks for your reply.
I don’t have the MailPro plug-in installed on the server (although if this can’t be resolved, I may have to use it!).

Thanks
Rafi

It is much easier to debug email issues by using credentials from code instead of the admin pages:

/**
 * @protected 
 * @properties={typeid:35,uuid:"DF42E17D-D034-4C19-9F31-D291BF234CF4",variableType:-4}
 */
var _server = [
	'mail.smtp.host=smtp.gmail.com',
	'mail.smtp.port=587',
	'mail.smtp.auth=true',
	'mail.smtp.username=something@gmail.com',
	'mail.smtp.password=password',
	'mail.smtp.starttls.enable=true'
];

/**
 * 
 * API:		Email
 * Simple email handling
 * 
 * @properties={typeid:35,uuid:"3A71702B-A25C-4E18-900F-CD83DA6B32CA",variableType:-4}
 */
var email = {
	/**
	 * Send email
	 * 	
	 * @param {{to:String, from:String, subject:String, body:String}} data email data points
	 * @param {_server} [server] server to use
	 */
	send : function(data, server) {
		
		// handle optional server
		/** @type _server */
		var srvr	 = (!server) ? _server : server
				
		// send email
		var success = plugins.mail.sendMail(
						data.to,
						data.from,
						data.subject,
						data.body,
						null,
						null,
						null,
						srvr)
						
		return success
		
	}
}

This makes it easy to play with the various properties listed at https://javamail.java.net/nonav/docs/ap … mmary.html.

In your case, note the line: “Note that if you’re using the “smtps” protocol to access SMTP over SSL, all the properties would be named “mail.smtps.*”.” So try:

var _server = [
	'mail.smtps.host=smtp.gmail.com',
	'mail.smtps.port=587',
	'mail.smtps.auth=true',
	'mail.smtps.username=something@gmail.com',
	'mail.smtps.password=password',
	'mail.smtps.starttls.enable=true'
];

I’ve spent a few hours wrangling connections to various email servers (takes restarting developer quite often unfortunately) – it’s just a matter of experimenting until it works.

Hi David,
once again, thanks for your help.
By putting the params into the code I discovered that the issue was

mail.smtp.ssl.enable=true

which is enabled on the live Servoy 5 server, which is working, so we had it enabled on the test Servoy 6 server, but this was causing the problem!
By removing the setting (and putting params back on server) it is all working now :D

I guess this is one for the books and I hope this helps someone else :wink:

Thanks
Rafi

rafig:
By putting the params into the code I discovered that the issue was

mail.smtp.ssl.enable=true

which is enabled on the live Servoy 5 server, which is working, so we had it enabled on the test Servoy 6 server, but this was causing the problem!
By removing the setting (and putting params back on server) it is all working now

Ah yea, I remember we had that setting in on Servoy 5’s too and now we don’t. Thought it was a mail server-specific thing though. Does indeed look like a change in the mail plugin between versions instead.

david:
Ah yea, I remember we had that setting in on Servoy 5’s too and now we don’t. Thought it was a mail server-specific thing though. Does indeed look like a change in the mail plugin between versions instead.

Obviously not mail server specific…

Servoy staff, please could you confirm and then maybe document if there is a change here (as it probably applies to 7 as well)??? :)

Thanks
Rafi