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?


In reply to Can only connect to XMPP server as anonymous@unknown.com with perl Net::XMPP module by gauss76

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.