Favorite Email Sending Technique

I made an automation script for a few customers. One nice feature is that when it ran into an error it sent me an email. I was trying to make it generic, so I used a bunch of terminal commands to turn on postfix. It worked well in Yosemite but now when an error presents itself I get 40 emails instead of 1. Apparently, the smtp wasn’t closing the session. This morning the email server started merging emails from different sources, yikes! I now have another script I will soon roll out to 25 users. The question I have is what do you folks like for sending emails ?

Scripting Mail.app has always annoyed me but its doable. Of course, there is the issue of what mail client the users uses… Do I sense the mail client then have different handlers for each option? (Outlook, Thunderbird, Mailsmith, etc., etc…)

Is there a really sweet implementation in Unix that does things properly? (And closes sessions.)

Someone suggested an OSAX - I had forgotten about those…

Something else I’m not thinking about?

What do you folks like?



The only OSAX I remember now has a cost, and in my experience is not 100% reliable. I’ve scripted Mail (agree with you about annoyance), Outlook and Airmail. But there are risks associated with each.

I would suggest a not fully automated approach. Have the script keep a log. When an error happens, reveal the log and prompt the user to send it to you. An alternate approach would be to place the log (formatted as .txt or .html) in a shared location where you can view it, either via web hosting or a dropbox-like service.


Thanks for responding !
I put a lot of work into that sendmail script. It will be hard to let it go, but I think you are right… I can’t imagine doing up with a mail script for every mail client. I think there’s about 15 of them or so, maybe more.
I think I need a good way to give the users a very detailed message about what happened and tell them what to do, to call me or whatever. I’m thinking of a series of documents based on each handler and maybe opening Text Edit with the appropriate one… AppleScript dialogs aren’t going to cut it, I think… Comments and ideas welcome…
Thanks for helping me think this thru…


I just create plain .txt logs using open for access and write. Quick and simple. On a major error, tell to the Finder to reveal where the file is to make it easy for the client to e-mail it to you.

You can use TextEdit if you want formatting. Or for live updates simply have the script open the .txt file in TextWrangler/BBEdit, if available.


I hate scripting TextEdit. IMO, Tex-Edit Plus is much, much better for scripting, and it is free.

1 Like