Error while authentication in Mailing Program

Hi Experts,

I am using below Perl script to send mail through and Microsoft Exchange server.
#!/usr/bin/perl -w
use SendMail;

$smtpserver          = "exchange_server.com";
$smtpport            = 25;
$sender              = "ABC\@def.com";
$subject             = "TESTING SMTP Server";
$recipient           = "mymailid\@def.com";
$header              = "X-Mailer";
$headervalue         = "Perl SendMail Module 1.09";
$mailbodydata        = "This is a testing mail.";
$userid              = "ABC\@AAA.com";
$password            = "passwd";


$obj = new SendMail($smtpserver,$smtpport);
$obj->setDebug($obj->ON);
$obj->From($sender);
$obj->Subject($subject);
$obj->To($recipient);
$obj->setMailHeader($header, $headervalue);
$obj->setMailBody($mailbodydata);
$obj->setAuth($obj->AUTHLOGIN, $userid, $password);
#$obj->setAuth($obj->AUTHPLAIN, $userid, $password);

if ($obj->sendMail() != 0)
{
    print "Error in Sending Mail.\n";
    print $obj->{'error'}."\n";
    exit -1;
}
else
{
    print "Done\n\n";
    exit 0;
}

And I am getting below error

220 in-ex004.groupinfra.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at  Mon, 5 Oct 2009 11:40:52 +0530
EHLO mymachine.com
250-exchange_server.com Hello [111.222.3.1]
250-TURN
250-SIZE 20971520
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM
250-AUTH GSSAPI NTLM
250-X-LINK2STATE
250-XEXCH50
250 OK
AUTH LOGIN
Error in Sending Mail.
504 5.7.4 Unrecognized authentication type.

If I comment the setAuth() function i.e., below line
$obj->setAuth($obj->AUTHLOGIN, $userid, $password);

I am getting below error.

220 exchange_server.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at  Mon, 5 Oct 2009 11:45:43 +0530
EHLO mymachine.com
250-exchange_server.com Hello [111.222.3.1]
250-TURN
250-SIZE 20971520
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM
250-AUTH GSSAPI NTLM
250-X-LINK2STATE
250-XEXCH50
250 OK
MAIL FROM: <ABC\@def.com>
454 5.7.3 Client does not have permission to submit mail to this server.
RCPT TO: <mymailid\@def.com>
DATA
To: mymailid\@def.com
From: ABC\@def.com
Subject: TESTING SMTP Server
X-Mailer: Perl SendMail Module 1.09

This is a testing mail.

.
QUIT
The mail has been sent to 1 person/s successfully.
Done

I think errors are due to incorrect authentication. All the informations except the authentication type is correct. Can anybody help me in finding the correct authentication type. Any other program in shell script, or Java, C to send mail with authentication option will also do.

Thanks

Ranjith

Your server expects either GSSAPI or NTLM authentication, and won't allow any simple authentication:

250-AUTH GSSAPI NTLM

If the module you're using supports those authentication schemes, use them. If not, Net::SMTP_auth supports NTLM via the Authen::NTLM module.