use MIME::Lite; # set up email $to = "myname\@domain.com"; $from = "myname\@domain.com"; $subject = "Email Sent via Perl"; $message = "This email was sent using Perl."; # send email email($to, $from, $subject, $message,); # email function sub email { # get incoming parameters local ($to, $from, $subject, $message) = @_; # create a new message $msg = MIME::Lite->new( From => $from, To => $to, Subject => $subject, Data => $message ); # send the email MIME::Lite->send('smtp', 'microsoft.exchange.server', AuthUser=>'myname', AuthPass=>'my_password', Debug=>1); $msg->send(); } #### MIME::Lite::SMTP>>> MIME::Lite::SMTP MIME::Lite::SMTP>>> Net::SMTP(2.29) MIME::Lite::SMTP>>> Net::Cmd(2.26) MIME::Lite::SMTP>>> Exporter(5.58) MIME::Lite::SMTP>>> IO::Socket::INET(1.29) MIME::Lite::SMTP>>> IO::Socket(1.29) MIME::Lite::SMTP>>> IO::Handle(1.25) MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 220 CAS1.microsoft.exchange.server Microsoft ESMTP MAIL Service ready at Mon, 4 May 2009 13:39:01 +0530 MIME::Lite::SMTP=GLOB(0x1b5e3e4)>>> EHLO localhost.localdomain MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-CAS1.microsoft.exchange.server Hello [172.16.4.115] MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-SIZE 10485760 MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-PIPELINING MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-DSN MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-ENHANCEDSTATUSCODES MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-STARTTLS MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-AUTH GSSAPI NTLM MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-8BITMIME MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250-BINARYMIME MIME::Lite::SMTP=GLOB(0x1b5e3e4)<<< 250 CHUNKING No SASL mechanism found at C:/Perl/site/lib/Authen/SASL.pm line 74