- $ref->{msgno} = next_transno("Msgno") if !$ref->{file};
- push @{$ref->{gotit}}, $f[2]; # mark this up as being received
- $ref->store($ref->{lines});
- add_dir($ref);
- my $dxchan = DXChannel->get($ref->{to});
- $dxchan->send("New mail has arrived for you") if $dxchan;
- Log('msg', "Message $ref->{msgno} from $ref->{from} received from $f[2] for $ref->{to}");
+ if ($ref->{file}) {
+ $ref->store($ref->{lines});
+ } else {
+
+ # does an identical message already exist?
+ my $m;
+ for $m (@msg) {
+ if ($ref->{subject} eq $m->{subject} && $ref->{t} == $m->{t} && $ref->{from} eq $m->{from}) {
+ $ref->stop_msg($self);
+ my $msgno = $m->{msgno};
+ dbg('msg', "duplicate message to $msgno\n");
+ Log('msg', "duplicate message to $msgno");
+ return;
+ }
+ }
+
+ # look for 'bad' to addresses
+ if (grep $ref->{to} eq $_, @badmsg) {
+ $ref->stop_msg($self);
+ dbg('msg', "'Bad' TO address $ref->{to}");
+ Log('msg', "'Bad' TO address $ref->{to}");
+ return;
+ }
+
+ $ref->{msgno} = next_transno("Msgno");
+ push @{$ref->{gotit}}, $f[2]; # mark this up as being received
+ $ref->store($ref->{lines});
+ add_dir($ref);
+ my $dxchan = DXChannel->get($ref->{to});
+ $dxchan->send($dxchan->msg('msgnew')) if $dxchan;
+ Log('msg', "Message $ref->{msgno} from $ref->{from} received from $f[2] for $ref->{to}");
+ }