+sub notify
+{
+ my $ref = shift;
+ my $to = $ref->{to};
+ my $uref = DXUser->get_current($to);
+ my $dxchan = DXChannel->get($to);
+ if (((*Net::SMTP && $email_server) || $email_prog) && $uref && $uref->wantemail) {
+ my $email = $uref->email;
+ if ($email) {
+ my @rcpt = ref $email ? @{$email} : $email;
+ my $fromaddr = $email_from || $main::myemail;
+ my @headers = ("To: $ref->{to}",
+ "From: $fromaddr",
+ "Subject: [DXSpider: $ref->{from}] $ref->{subject}",
+ "X-DXSpider-To: $ref->{to}",
+ "X-DXSpider-From: $ref->{from}\@$ref->{origin}",
+ "X-DXSpider-Gateway: $main::mycall"
+ );
+ my @data = ("Msgno: $ref->{msgno} To: $to From: $ref->{from}\@$ref->{origin} Gateway: $main::mycall",
+ "",
+ $ref->read_msg_body
+ );
+ my $msg;
+ undef $!;
+ if (*Net::SMTP && $email_server) {
+ $msg = Net::SMTP->new($email_server);
+ if ($msg) {
+ $msg->mail($fromaddr);
+ $msg->to(@rcpt);
+ $msg->data(map {"$_\n"} @headers, '', @data);
+ $msg->quit;
+ }
+ } elsif ($email_prog) {
+ $msg = new IO::File "|$email_prog " . join(' ', @rcpt);
+ if ($msg) {
+ print $msg map {"$_\r\n"} @headers, '', @data, '.';
+ $msg->close;
+ }
+ }
+ dbg("email forwarding error $!") if isdbg('msg') && !$msg && defined $!;
+ }
+ }
+ $dxchan->send($dxchan->msg('m9')) if $dxchan && $dxchan->is_user;
+}
+