The problem I have is that the hook I defined is not being called on the event "user_send_packet". I did assume that any stanza (including messages) that is being sent would trigger this event.
I have taken into account the priority of how the hook is being called by setting it to '0'. In the log I have verified that the module is started ("mod_stanza_ack starting"). The erl file did compile, it only got the warning "gen_mod" is undefined, but I have read on a ejabberd mailing list that this is harmless and also that the variable "Host" is unused in line 12. Maybe this has something to do with it, but I cannot find out if this is the case.
-module(mod_stanza_ack).
-behaviour(gen_mod).
-include("ejabberd.hrl").
-export([start/2,
stop/1]).
-export([on_user_send_packet/3]).
start(Host, _Opts) ->
?INFO_MSG("mod_stanza_ack starting", []),
ejabberd_hooks:add(user_send_packet, global, ?MODULE, on_user_send_packet, 0),
ok.
stop(Host) ->
?INFO_MSG("mod_stanza_ack stopping", []),
ejabberd_hooks:delete(user_send_packet, global, ?MODULE, on_user_send_packet, 0),
ok.
on_user_send_packet(From, To, Packet) ->
?INFO_MSG("mod_stanza_ack a package has been sent coming from: ~p", [From]),
?INFO_MSG("mod_stanza_ack a package has been sent to: ~p", [To]),
?INFO_MSG("mod_stanza_ack a package has been sent with the following packet: ~p", [Packet]),
Packet.