use Milkbone; use Net::SMTP; use strict; use warnings; sub sendmail { print "sending message";; my ($sub, $text, $user) = @_; $user =~ s/ /_/g; my $smtp = Net::SMTP->new(option('MonitorServer'), Hello => 'milkbone.org', Debug => 1); $smtp->auth(option("MonitorUser"), option("MonitorPass")) if option("MonitorUser"); $smtp->mail("$user\@milkbone.org"); $smtp->to(option('MonitorRecipient')); $text =~ s/<.*?>//g; $smtp->data(); $smtp->datasend("To: \n"); $smtp->datasend("From: Milkbone Monitor <$user\@milkbone.org>\n"); $smtp->datasend("Subject: $user - $sub \n"); $smtp->datasend("\n"); $smtp->datasend("$user - $text"); $smtp->dataend(); $smtp->quit; } register_hook("msg_in", sub { return unless hook("protocol_away_status"); sendmail('Message Received', "Received the following message from $ARGS{-user}:\n\n$ARGS{-msg}", $ARGS{-user}); }); 1;