連線和傳送訊息

SleekXMPP(Python)

import sleekxmpp

client = sleekxmpp.Client("address@example.net", "password")
client.connect()
client.process(blocking=False)
client.send_message(mto="remote@example.net", mbody=self.msg)

Smack(Java / Android)

XMPPTCPConnection connection = new XMPPTCPConnection("user", "password", "example.org")
connection.connect().login();
Message message = new Message("otheruser@example.net", "Hi, how are you?");
connection.sendStanza(message);
connection.disconnect();