Modern email library

Richard Gaskin ambassador at fourthworld.com
Wed Nov 30 11:42:13 EST 2016


Ben Rubinstein wrote:

 > I've one app that's been in existence for over a decade, which uses
 > Shao Sean's libSmtp. It works fine.
 >
 > Now I find myself wanting to send email from a new stack I'm working
 > on. I could just drag that library out again, but I suspect that a
 > more modern way is to use tsNet.
 >
 > AFAICT tsNet handles the protocol of communicating with the server to
 > transmit a message (i.e. the SMTP part), but doesn't offer any
 > assistance with putting the message together (formatting with
 > attachments etc).
 >
 > What do modern people use for this? Obviously I could rip the
 > relevant parts out of libSMTP; or I recall that Sarah Reichelt had
 > a library; is there a default answer among those who've sent email
 > in the last ten years?

Personally, I've never been comfortable relying on client-side SMTP.  I 
figure that any device configured to allow any app to send arbitrary 
emails without explicit user intervention will eventually become a 
spambot, so my hope is that it's only a matter of time before the OS 
provider puts an end to that.

For most systems I prefer to use the "mailto:" protocol to open a 
message in the user's own email client, so they can review it and decide 
whether they actually want to send it.

I do have some monitoring systems that provide notification, but I don't 
usually install email on a server designed for any other purpose.

So instead I maintain one server on one of my shared hosting accounts as 
a notification center (it's not used often enough to warrant a VPS, but 
if you expect heavy load VPSes are cheap these days).  It runs an LC CGI 
that accepts a compressed encoded array containing the email elements 
(to, from, subject, body, etc.), and it formats it for use by sendmail, 
which it then calls from the command line.

The advantages with using an external server to do the actual sending are:

- I'm not dependent on a local SMTP client implementation, which I
   hope for security's sake won't always be available.

- It uses a simple one-line call to a server, so it's easy to
   add email support in any client app wherever I need it.

- The CGI is relatively simple to set up (Lesson examples available
   for using sendmail with LC CGI).

- The server is reasonably protected (nothing is *absolutely*
   protectable) by virtue of only accepting the LC-specific LSON
   (encoded array) format, which is also encrypted before sending,
   and transmitted over HTTPS.

By no means perfect (nothing is a magic pony), but easy to set up, 
convenient to use, and at least as secure as most alternatives.

I don't currently send attachments, but the MIME format is well 
documented and LC provides the raw materials needed (good text handling 
and base64 encoding), so even if a current library isn't readily 
available it shouldn't take long to package up an attachment with the body.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list