get send email work with yosemite

Get SendEmail working with Yosemite and Mavericks

Get SendEmail working with Yosemite and Yosemite using SSL

A while back, we found a nice little command line tool to send emails with authentication settings, custom subjects, etc., without using any of the built in email sending tools. This was handy for situations where a client might have various restrictions in place such as a relay server that requires authentication and / or a specific sender address to allow the emails to pass through.

The tool is called “SendEmail” and is available from the Caspian webpage for free! We commonly used this with a number of custom client-side notification systems.

Sounds handy, what changed? 

Mavericks:

Well, the solution is a script written in Perl, making use of the default Perl language installing and modules. With Mavericks, Apple added a newer default version of Perl, with which the script could not use the SSL Module for SSL communications

The main issue is that the developer is no longer actively developing this tool and so there is no full patch for the issue. After a short while, one of the commenters on the page posted a simple fix that involves editing the SendEmail tool to use the older, yet still included version of Perl, 5.12.

This is to open the script in a text editor (avoid TextEdit and use the free TextWrangler if possible), and modify the first line from:

#!/usr/bin/perl –w

To:

#!/usr/bin/perl5.12 –w

And save the new script. This should now work fine in Mavericks.

Yosemite:

With Yosemite, Apple removed the older Perl version meaning that the above fix no longer works. We have to make some more tweaks to the script and grab the single required module from the Perl 5.12 modules.

1. Find the Perl 5.12 Extras directory on a copy of Mac OS X Mavericks or Mountain Lion. This is located at “/System/Library/Perl/Extras/5.12”.

2. Grab the specific SSL.pm Perl Module from “/System/Library/Perl/Extras/5.12/IO/Socket/SSL.pm” and copy this to a location of your choosing. We typically use a /Library folder for our installations. E.g. “/Library/Amsys/Perl5.12/”. I would suggest you do the same and DO NOT modify your own “/System/Library” folder contents (this is because this area is Apple’s domain so any updates and definitely any upgrades will replace this folder).

3. Reopen the SendEmail script in a text editor of your choice.

4. If you made the above changes for Mavericks, we need to reverse these to use the default Perl language version. Modify the first line from:

#!/usr/bin/perl5.12 –w

Back to:

#!/usr/bin/perl –w

5. Now we need to tell the SendEmail script to use the extra SSL Module we have grabbed. Around lines 128 to 133 you’ll see this:

## Load IO::Socket::SSL if it's available
eval { require IO::Socket::SSL; };
if ($@) { $conf{'tls_client'} = 0; }
else { $conf{'tls_client'} = 1; }

Change this to:

## Load IO::Socket::SSL if it's available
use lib '/Library/Amsys/Perl5.12';
use SSL;
#eval { require IO::Socket::SSL; };
if ($@) { $conf{'tls_client'} = 0; }
else { $conf{'tls_client'} = 1; }

And change the highlighted section to the path where you have put your Perl v5.12 SSL.pm module file.

6. Run some tests and checks and this should all work. If you’re having issues, check that the Library folder/s and the SSL.pm file are owned by Root with 755 as the permissions (or however you specific implementation requires them).

Looking Forward

OK, I confess, this is a large bit of gaffer tape stuck over cracks in the script, but it’ll get most people who may use it out of a hole with the least amount of faff.

In the future, I’ll need to tear the script apart and find out what specifically it doesn’t like with the SSL module in the newer versions of Perl and correct this. As with most IT guys, it’s on a ‘To Do’ list, just not very high up it!

Summary

I hope this help anyone else who uses SendEmail to continue use a nice little tool for command line email sending!

As always, if you have any questions, queries or comments, let us know below and I’ll try to respond to and delve into as many as I can.

3 Replies to "Get SendEmail working with Yosemite and Mavericks"

  • Devin

    Works like a charm, thanks.

    Worth noting is that users on Yosemite accessing the iCloud Mail server who have set up two-step verification will need to generate an app-specific password for sendEmail.

    It’s unfortunate the developer has ceased development. It’s such a useful tool that deserves an update. I look forward to what you can do with it!

  • Darren Wallace

    Hi Devin,
    Thanks for the message and the additional information.

    I’d love to look into and fix the issue ‘properly’ but that would require me to learn Perl properly so I can’t promise it’ll be soon!

    Darren

Leave a Reply

Your email address will not be published. Required fields are marked *