[ejabberd] Sen message from ejabberd plugin

Alexander Kuleshov kuleshovmail at gmail.com
Thu Nov 3 10:30:54 MSK 2011


I have simple ejabebrd plugin and i need to esn message from it.

My code:

send_message(TypeStr, BodyStr) ->
    LUser = "test1",
    LServer = "localhost",
    From1 = jlib:make_jid(LUser, LServer, "fb"),

    TUser = "test2",
    TServer = "localhost",
    To1 = jlib:make_jid(TUser, TServer, "fb"),

    FromAddress = jlib:jid_to_string(From1),
    ToAddress = jlib:jid_to_string(To1),

    XmlBody = {xmlelement, "message", [{"type", TypeStr}, {"from",
FromAddress}, {"to", ToAddress}], [{xmlelement, "body", [], [{xmlcdata,
   ejabberd_router:route(From, To, XmlBody).

But i get error:

=ERROR REPORT==== 2011-11-03 13:27:12 ===
E(<0.494.0>:ejabberd_router:70) : {{badrecord,jid},



when processing: {"test1 at localhost","test2 at localhost",
  {"from","test1 at localhost/fb"},
  {"to","test2 at localhost/fb"}],
  [{xmlelement,"body",[],[{xmlcdata,"test test"}]}]}}

How can i fix it? How can i send message from ejabberd plugin?

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20111103/d45eeec5/attachment.html>

More information about the ejabberd mailing list