Send mail using Perl script (TLS) for office 365

Thanks to Joshua F.

Following script will send the mail with TLS using office 365 smtp.

Note: you must have office 365 account.

first you need to install the Net::SMTP:TLS using cpan

[root@localhost ~]# cpan
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]> install Net::SMTP:TLS

create file and copy following script to that file.

Note: Change Red mark contain.

use strict;
use Net::SMTP::TLS;  
my $mailer = new Net::SMTP::TLS(  
    Port    =>      587,  
    Hello   =>      '',
    User    =>      'Username-Email-ID',
    Password=>      'Password',
    Debug   => 1) || die "Cannot connect to smtp server";
$mailer->datasend("Sent from perl!");  
Posted in Office 365

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: