Jump to content
Server Maintenance This Week. ×

smtp port 587 (or other than 25)


This topic is 2103 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi guys - first - a warm thank you for making this plugin available, we have used Scriptmaster for 4 years now and have had NO problems until now - please advise:

The setup: FMS 13 on Windows 2008R2, ScriptMaster 4.1 and once a month a Email-blast with a few Emails/PDFs to recipients - no problems !

Now: we are relocating to another smtp-gateway, which only supports port 587....!   And THEN no more mails !

I have read/googled for days now, so i think I have tried the most common solutions, to no avail....

This is our code i SM-INIT-script and I THINK that its the "port" statement that is wrong:

---------cut------------

//Load ScriptMaster Functions

//HTMLEmail Function
RegisterGroovy (
"HTMLEmail ( from ; to ; cc ; bcc ; subject ; htmlbody ; attachmentPath ; smtpHost )" ;
"import javax.mail.*;¶
import javax.mail.internet.*;¶

Properties props = new Properties();¶
props.setProperty(\"mail.smtp.host\", smtpHost);¶

props.setProperty (\"mail.smtp.port\", \"587\");¶

MimeMessage msg = new MimeMessage(Session.getInstance(props));¶

-------------------cut---------------------------------
 

The BOLD line is the new one - it was´nt in the code, so I assume it has to be inserted to work on other ports than default port 25....

I have tried to load NEW ScriptMaster (5.05) plugin, new activation.jar and mail.jar, but nothing helps...

The ScriptMaster 5.05 even halts FM Pro Advanced on serverconsole AND the server plugin (64 bits version) refuses to load for some reason - but THIS is not important - unless of course its going to be a part of the solution on this problem...

Anyone has a clue ??

Thank you in advance !

 

Lars G.

Link to comment
Share on other sites

Can you post the whole function and a list of the jars you are using...

 

first look props.setProperty (\"mail.smtp.port\", \"587\");¶

looks wrong - should be "mail.smtp.port", 587 - its a number not a string

Link to comment
Share on other sites

Hi John and thanks for replying - the quotes are in place because the whole text is... ehm... FileMaker-text and so the "´s is preceeded with a \, thus can I get values from variables as parameters....

The calculation - without the PORT-line - has been running PERFECT in 3-4 years - so I have to assume that the other code is OK !

The format you wrote - is that verified ??  I mean, do you know for sure its OK ??

 

Thanks again !

Oops sorry, forgot to show code:

Below is the complete INIT-code for the ScriptMaster-plugin - it works wonderfully, but i can´t figure out where to change the port...:

 

//Load ScriptMaster Functions

//HTMLEmail Function
RegisterGroovy (
"HTMLEmail ( from ; to ; cc ; bcc ; subject ; htmlbody ; attachmentPath ; smtpHost )" ;
"import javax.mail.*;¶
import javax.mail.internet.*;¶

Properties props = new Properties();¶
props.setProperty(\"mail.smtp.host\", smtpHost);¶

props.setProperty (\"mail.smtp.port\", \"587\");¶

MimeMessage msg = new MimeMessage(Session.getInstance(props));¶

if (attachmentPath == null) {¶
  // HTML E-Mail Only¶

  msg.setContent(htmlbody, \"text/html\");¶

else {¶
  // HTML E-Mail with Attachment(s)¶

  Multipart content = new MimeMultipart();¶

  // first the message body¶
  MimeBodyPart bodyPart = new MimeBodyPart();¶
  bodyPart.setContent(htmlbody, \"text/html\");¶
  content.addBodyPart(bodyPart);¶

  // then the attachment(s)¶
  attachmentPath.tokenize(\";\").each {it ->¶
    attachmentPart = new MimeBodyPart();¶
    attachmentPart.attachFile it;¶
    content.addBodyPart attachmentPart;¶
  }¶

  msg.setContent(content);¶

msg.setSubject(subject);¶
msg.setFrom(new InternetAddress(from));¶

to.tokenize(\";\").each {it ->¶
  msg.addRecipients(Message.RecipientType.TO, new InternetAddress(it))¶

if (cc != null){¶
  cc.tokenize(\";\").each {it ->¶
    msg.addRecipients(Message.RecipientType.CC, new InternetAddress(it))¶
  }¶

if (bcc != null){¶
  bcc.tokenize(\";\").each {it ->¶
    msg.addRecipients(Message.RecipientType.BCC, new InternetAddress(it))¶
  }¶

Transport.send(msg);¶
return true;¶")

Link to comment
Share on other sites

Here is some code that works from G-Mail using port 587 and TLS

replace where obvious

Groovy code note: you dont need the ';' at the end of lines and in most cases you can use ' and not " as the string delimeiters, which makes it better to debug when in FileMaker

// gmailTest()
// v1.0
// 17_09_16
// J Renfrew
//

import javax.mail.Message
import javax.mail.MessagingException
import javax.mail.PasswordAuthentication
import javax.mail.Session
import javax.mail.Transport
import javax.mail.internet.InternetAddress
import javax.mail.internet.MimeMessage
 
username = '[email protected]'
password = 'PASSWORD'
 
props = new Properties()
	props.put('mail.smtp.auth', 'true')
	props.put('mail.smtp.starttls.enable', 'true')
	props.put('mail.smtp.host', 'smtp.gmail.com')
	props.put('mail.smtp.port', '587')
 
session = Session.getInstance(props,
	new javax.mail.Authenticator() {
		protected PasswordAuthentication getPasswordAuthentication() {
			return new PasswordAuthentication(username, password)
		} //end authentication
	} //end authenticator
) //end session
 
try {
 
	message = new MimeMessage(session)
		message.setFrom(new InternetAddress('[email protected]'))
		message.setRecipients(Message.RecipientType.TO, InternetAddress.parse('[email protected]'))
		message.setSubject('Testing Subject')
		message.setText('Dear ScriptMaster,' + '\n\n No spam to my email, please!')
 
	Transport.send(message)
 
	return true
 
} catch (e) {
	return e.getMessage()
} //end try

 

You will need to work out how to make this send HTML and multipart HTML but that shouldn't be too hard.

This ALSO is confirmed to work with Office 365 on smtp.office365.com

 

Edited by john renfrew
Link to comment
Share on other sites

Ohh, GREAT John, thank you so much, I will try your code ASAP and return the result to you here...

 

Thanks again !

 

Kind regards, Gokke

Link to comment
Share on other sites

  • 2 weeks later...

Allright, as promised, status on this problem is - Im no longer using the ScriptMaster plugin !

I was unable to get this Javacode above to work (i´m NO Java-hacker at all !) in due time, I could not find any relevant documentation and could not interpret the errormessages from the Groovy code - so - trying out other stuff, I found myself installing the BaseElement plugin on the server.... And with help from the online docs and after some testing, it was up and running within one hour !

I LOVE the ScriptMaster plugin and uses this alot - but Im simply too stupid to do Java code embedded within Groovy, embedded within FileMaker.... 

Thanks for your help anyway !

Kind regards, Lars G.

Link to comment
Share on other sites

  • 9 months later...

Hi Lars,

I've only just seen this thread. It looks like you're using the HTMLEmail Script which I wrote (with a lot of help from Google/forums). The new version works with Authentication as we also switched to an authenticated SMTP server.

Link to comment
Share on other sites

This topic is 2103 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.