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;
No comments:
Post a Comment