gauss76 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to connect to an XMPP server and send a message to another user using the following perl code

(taken from https://roadha.us/2011/04/send-xmpp-messages-with-perl-from-the-command-line-too.html).

It works but the mesage is sent from anonymous@unknown.com. I know this because I have Pidgin running as another user on the same XMPP server and recieve the message from my perl program from anonymous@unknown.com. Pidgin also shows anonymous@unknown.com as offline!

#!/usr/bin/perl use strict; use Net::XMPP; my ($recip, $msg) = @ARGV; if(! $recip || ! $msg) { print 'Syntax: $0 <recipient> <message>\n'; exit; } my $con = new Net::XMPP::Client(); my $status = $con->Connect( hostname => 'xx.xx.xx.xx',port=>5222, connectiontype => 'tcpip',tls => 0); die('ERROR: XMPP connection failed') if ! defined($status); my @result = $con->AuthSend( username => 'Uname', password => 'PWord', resource=>'Test'); die('ERROR: XMPP authentication failed') if $result[0] ne 'ok'; die('ERROR: XMPP message failed') if ($con->MessageSend(to => $recip, +body => $msg) != 0); print 'Success!\n';

From the code I would expect to by connected as Uname. Why is this not the case?

  • Comment on Can only connect to XMPP server as anonymous@unknown.com with perl Net::XMPP module
  • Download Code