Monday, 14 May 2018

Sending Office 365 emails with perl - invalid SSL_version

In our case, we are sending an email through Office 365 using Net::SMTP::TLS. But apparently that module is broken and unmaintained. We installed the process on a new machine and ran into the problem.

We are getting this error:

invalid SSL_version specified at C:/Strawberry/perl/vendor/lib/IO/Socket/SSL.pm line 444


We were able get it running using a different module: Net::SMTPS. The following sample code sends a email message with an attachment.




use Net::SMTPS; 
         use MIME::Entity;

my $msg = MIME::Entity->build( 
Type => 'multipart/mixed',
    From => 'Some guy <someguy@callerip.ca>',
    To => 'anotherguy@callerip.ca',
    Subject => "My subject",
);
$msg->attach(
    Type     => 'application/pdf',
    Path     => "$file",
    Filename => "attachment.pdf",
    Encoding => 'base64'
);
# send the message
        my $smtp = Net::SMTPS->new("smtp.office365.com", Port => 587, doSSL => $ssl);
  $smtp->auth ( $user, $pass);

$smtp->mail($user);

$smtp->to( $to );
# Send the message and attachments
$smtp->data(  );
$smtp->datasend([ $msg->as_string ]);
$smtp->dataend;
$smtp->quit;

Saturday, 12 May 2018

Installing MCYRPT on a php::apache docker


Trying to install MCRYPT on a php:apache docker machine?

I found this to work:
RUN apt-get install -y libmcrypt-dev libreadline-dev
RUN pecl install mcrypt-1.0.1
RUN docker-php-ext-enable mcrypt