[Tip] Email plugin: dynamic SMTP authentication
by David Workman
Sotlex, Inc
Do you need to send mail with more than one SMTP server per Servoy server? As it turns out, the latest version of the mail plugin allows you to override the Server mail plugin settings for SMTP authentication when you use the sendMail function in a method.
Here's the format for sendMail. Notice the last input parameter:
boolean sendMail( to, from, subject, msgText, [cc], [bcc], [attachement/attachments array], [overridePreferenceSMTPHost/properties array])
The sample code for the function does not show what format the properties array for the SMTP host override should be. Here's an example that shows how to do this:
var authorization = new Array("mail.smtp.host=[smtp mail server]", "mail.smtp.auth=true",
"mail.smtp.username=[user name]", "mail.smtp.password=[password]");
var emailSend = "[email address]";
var emailFrom = "[email address]";
var emailSubject = "SMTP help";
var emailMsg = "test code";
var success = plugins.mail.sendMail(emailSend, emailFrom, emailSubject, emailMsg, null, null, null, authorization );
By switching out the values that this method recieves, you can control which SMTP mail server is used at the client level at runtime.
Comments (4)