Today’s post is by one of our lead developers. Mike Duncan
Updated Send Email Script (and sending email from your server)
You might be familiar with the way we’ve been able to use the “Send Email” step in previous versions of FileMaker, and those are all unchanged for the most part. Of course, it’s very easy to create a document such as a PDF brochure or Excel spreadsheet populated with data and send that as an attachement. As long as you’re using this from FileMaker Pro, this works great and there’s probably not an easier method of creating a PDF that is specific to the records in your database. Especially when using the Multiple Emails option to send one email for each record in a found set. Nice.
A new feature in FileMaker 10 is the ability to send email directly from FileMaker via SMTP. In the updated script step, you’ll find settings for an SMTP server. Almost all these settings can either be entered directly from the script, or by the result of a calculation if the values need to be more dynamic. The only settings you need to specify is the Authentication and if you’re using SSL. By the way, if you are using SSL, the port number does not automatically change for you. Usually, it’s port 465 for SSL and 25 for the regular non-SSL port.
This all means that when you send an email, we’re no longer dependant on an email client sending the email on our behalf. Hooray! Now for the bad news…
Unfortunately, the implementation falls short in some key areas, if you happen to need anything beyond basic functionality of sending email, that should keep various SMTP plug-in makers in business for a while. For most people, accepting HTML email is pretty standard nowadays, but if you want to send an HTML email (either nice looking reports or fancy marketing material) you’re out of luck with the built in tools FileMaker gives you. It’s plain text ONLY, with the consolation of including an attachment. I know that some email clients will display attachments inline, making this seem more like html email, but for me it falls short. I’m willing to live with the fact that some users can’t see HTML email, but I won’t expect attachments to show up in email messages for everyone. The people who deliberately turn off HTML email are increasingly in the minority, partly due to the fact that most modern email clients make it extremely difficult to do so. If you’re using a recent version of Outlook (on Windows) or Mail.app (on Mac OS) then take a few minutes and try to turn it off, I’ll wait.
Now let’s take a look at FileMaker Server and sending email.
More good news. This step is Server compatible, which means you can schedule it from the server, and it will send an email from FileMaker Server, without the need for a robot machine or similar nonsense! More bad news… the “Save records as PDF” script step is still NOT. So while you can send email from FileMaker Server 10, that groovy PDF won’t be able to be attached like you wanted. You also cannot “Export Field Contents” or “Save as Excel”, though these are somewhat available as a regular export.
This is state of the art 1995 for sending automated email. I can’t understand why adding an HTML option would be out of the question, but it’s just not here. I also don’t see why saving a PDF is also greyed out, but I’m sure there is a good reason behind it. It ends up being a feature I don’t see myself using too often because of these limitations. Of course, the ability to export records IS now able to run from the server, so you can export however you like and attach that to your email. And you can export as an excel spreadsheet this way, but not PDF.
So what are the options for sending email from FileMaker Server that might be more robust? I’m not aware of plug-ins that run server side, but there might be some that fit the bill that I’m not aware of. For me, using a web scripting language has filled this gap for some time now. PHP is the one used most now and is free and installed with FileMaker Server if you choose. It’s fairly easy to loop through found sets, and send an email to each record, with multi-part messages that will show both plain text as well as HTML. All the benefits of HTML email are available as well, including referencing images, complex html and clickable links. The payoff of a great end user experience is well worth the development.
There is plenty that FileMaker Server is capable of now from the server side other than just serve data. You can also imagine the possibilities of running some pretty complex scripts on the server that collect data that might be picked up by a php script that formats it as a nicely marked up html email and sends it out each night. Perhaps daily activity, or end of month sales reports, who knows. And no one needs to click a button to do it, or even launch FileMaker.
It’s worth mentioning that I’ve had good success with the phpmailer class for a more robust email sending method from PHP, which can be had for free from http://phpmailer.codeworxtech.com/ if you need it. It also allows for sending via sendmail from the server where PHP is installed, or you can specify a SMTP server as well.
The update to sending email from FileMaker is a welcome one, and much needed. The more robust options are still available and, in my opinion, still required. I will have to look forward to the addition of HTML in some future version.

