TulipeMoutarde.be    About

Send email from Pharo with Postmark

This blog post was written a long time ago and may not reflect my current opinion or might be technically out of date. Read with a grain of salt.

Written on December 29, 2011.

I recently needed to send emails from a Pharo image. There is a SMTP client integrated in the standard libray but I wanted to wrap the excellent Postmark REST API.

You can load it from SqueakSource 3:

Gofer it
     url: 'http://ss3.gemstone.com/ss/postmark';
     package: 'ConfigurationOfPostMark';
     load.

(Smalltalk at: #ConfigurationOfPostMark) project stableVersion load.

And you can use it like:

| email interface |
email := PMEmail new
  from: 'francois@wapict.be';
  to: 'francois@yopmail.com';
  subject: 'Test Application';
  textBody: 'Yeah baby';
  yourself.

interface := PMInterface new.
interface apiKey: 'blopblop'.

interface send: email.

The implementation is really basic and does not handle attachments at the moment. I use it on a staging application that will probably be in production in January. I will see how it behaves under small load and improve it if needed.

edit: you can now attach files to your emails !