I have a perl script that is used to send email from gmail, please let me know how can i use this script to send email from company's exchange server. i tried all possible changes but no success

#!c:\Perl\bin\perl # Program to check if the comp link files are generated in the FTP dir +ectory of STP. It will check past 1 hour files only use MIME::LITE; use Net::SMTP; use Email::Send; use Email::Send::Gmail; use Email::Simple::Creator; my ($sec,$min,$hour,$day,$month1,$yr19,@rest) = localtime(time); $year = $yr19+1900; $month = $month1+1; $leapyear = $year%4; $febcheck = "0"; if ($month < 10) { $month = "0".$month; } if ($day < 10) { $day = "0".$day; } print " Current Date is $year-$month-$day \n"; print " Current Time is $hour-$min-$sec \n"; $preverror = 0; $minp = '00'; $stp = 'vsnlmumstp'; $folder = 'stpmumbai'; errorcheck (); if ($errorlog == 1) { $fileprev = $filename; $preverror = 1; $minp = '30'; $stp = 'vsnlmumstp'; $folder = 'stpmumbai'; errorcheck (); email (); } $preverror = 0; $minp = '00'; $stp = 'vsnlndlstp'; $folder = 'stpdelhi'; errorcheck (); if ($errorlog == 1) { $fileprev = $filename; $preverror = 1; $minp = '30'; $stp = 'vsnlndlstp'; $folder = 'stpdelhi'; errorcheck (); email (); } sub errorcheck { $errorlog = 0; $start = $hour - 1; for ($i = $start; $i < $hour; $i++) { if ($i <= 9) { $hourp = "0".$i; } else { $hourp = $i; } $timecombo = $hourp.$minp; $filename =$stp."_comp-link_".$month.$day."_".$hourp.$minp.".c +sv"; $filepath = "\\\\192.168.10.212\\e\\$folder"; $filetocheck = "$filepath\\$filename"; print "\n Opening Dir for $filetocheck\n"; $errordir = 0; opendir(DIR, "\\\\192.168.10.212\\e\\$folder") || ($errordir = + 1); if ($errordir == 1) { emaildir (); die "Not able to access remote directories \n";; } @files = grep /$filename/, readdir(DIR); closedir(DIR); if ($#files != 0) { $errorlog = 1; } } } sub emaildir { print "\n sending mail for Directory access failure \n"; $path1 = "\"d:\\data\\Comp_Link_Scripts\\Comp_Link_RECI_Transf +er\""; $subject = "Alert_File transfer error for Comp Link File for s +tpdelhi and stpmumbai"; $email2 = 'a.gupta@company.com'; emailgmail1 (); $email2 = 'kunal.nakhawa@company.com'; emailgmail1 (); $email2 = 'ujjawal.khare@company.com'; emailgmail1 (); print "\n Mail Sent \n"; } sub emailgmail1 { my $email = Email::Simple->create( header => [ From => 'mepunetcl@gmail.com', To => $email2, Subject => $subject, ], body => 'Not able to connect to FTP server directories stpdelhi +and stpmumbai, Please check (Contact a.gupta@company.com for details) +', ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'mepunetcl@gmail.com', password => 'company@123', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@; } sub email { if (($errorlog == 1) && ($preverror == 1)) { print "\n sending mail \n"; $path1 = "\"d:\\data\\Comp_Link_Scripts\\Comp_Link_RECI_Transf +er\""; $subject = "Alert_File transfer error for $folder"; $email2 = 'nldvoice.noc@company.com'; emailgmail2(); $email2 = 'a.gupta@company.com'; emailgmail2(); $email2 = 'vishal.arya@company.com'; emailgmail2(); $email2 = 'anilkumar.singh@company.com'; emailgmail2(); $email2 = 'kunal.nakhawa@company.com'; emailgmail2(); $email2 = 'ujjawal.khare@company.com'; emailgmail2(); print "\n Mail Sent \n"; } } sub emailgmail2 { my $email = Email::Simple->create( header => [ From => 'mepunetcl@gmail.com', To => $email2, Subject => $subject, ], body => "File $filename & $fileprev missing, Please check (Conta +ct a.gupta\@company.com for details)", ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'mepunetcl@gmail.com', password => 'company@123', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@; }

In reply to how to use perl script to send email from exchange like we use perl for gmail server by ukhare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.