8 use Time
::HiRes qw
(usleep gettimeofday tv_interval
);
9 use POSIX
qw(:sys_wait_h errno_h signal_h);
13 use Net
::Server
::PreFork
;
14 use Net
::Server
::SIG
qw(register_sig check_sigs);
25 use Mail
::SpamAssassin
;
26 use Mail
::SpamAssassin
::NetSet
;
31 use PMG
::ClusterConfig
;
48 use base
qw(Net::Server::PreFork);
50 my $opt_commandline = [$0, @ARGV];
51 my $opt_max_dequeue = 1;
52 my $opt_dequeue_time = 30;
54 my $opt_ext_port = 10024;
55 my $opt_int_port = 10023;
56 my $opt_inject_port = 10025;
63 my $prog_name = 'pmg-smtp-filter';
65 initlog
($prog_name, 'mail');
67 if (!GetOptions
('testmode=s' => \
$opt_testmode,
68 'pidfile=s' => \
$opt_pidfile,
69 'untrusted' => \
$opt_untrusted,
70 'database=s' => \
$opt_database)) {
75 $opt_pidfile = "/var/run/${prog_name}.pid" if !$opt_pidfile;
79 my $min_spare_servers = 0;
80 my $max_spare_servers = 0;
83 # create spool directories
84 PMG
::MailQueue
::create_sppoldirs
();
88 my $pmg_cfg = PMG
::Config-
>new();
90 my $demo = $pmg_cfg->get('admin', 'demo');
93 syslog
('info', 'demo mode detected - not starting server');
97 $max_servers = $pmg_cfg->get('mail', 'max_filters') + 2;
99 $min_spare_servers = 1;
100 $max_spare_servers = 4;
104 $opt_max_dequeue = 0 if $opt_testmode;
107 if (defined ($ENV{BOUND_SOCKETS
})) {
112 port
=> [ $opt_int_port, $opt_ext_port ],
114 min_servers
=> $min_servers,
115 max_servers
=> $max_servers,
116 min_spare_servers
=> $min_spare_servers,
117 max_spare_servers
=> $max_spare_servers,
118 max_requests
=> $max_requests,
119 serialize
=> 'flock',
120 max_dequeue
=> $opt_max_dequeue,
121 check_for_dequeue
=> $opt_dequeue_time,
123 pid_file
=> $opt_pidfile,
124 no_close_by_child
=> 1,
125 no_client_stdout
=> 1,
126 commandline
=> $opt_commandline,
129 $server_attr->{setsid
} = $daemonize if !$opt_testmode;
133 if (defined($opt_database)) {
134 $database = $opt_database;
136 $database = $opt_testmode ?
"Proxmox_testdb" : "Proxmox_ruledb";
139 $SIG{'__WARN__'} = sub {
143 syslog
('warning', "WARNING: %s", $t);
148 my ($self, $queue, $entity, $msginfo, $rule, $targets, $spaminfo) = @_;
151 sa_score
=> $queue->{sa_score
},
152 sa_hits
=> $queue->{sa_hits
},
153 sa_data
=> $queue->{sa_data
},
154 sa_max
=> $queue->{sa_max
}
158 'SUBJECT' => $entity->head->get ('subject', 0) || 'No Subject',
159 'RULE' => $rule->{name
},
160 'RULE_INFO' => $msginfo->{rule_info
},
161 'SENDER' => $msginfo->{sender
},
162 'SENDER_IP' => $msginfo->{xforward
}->{addr
},
163 'TARGETS' => join (', ', @$targets),
164 'RECEIVERS' => join (', ', @{$msginfo->{targets
}}),
165 'SPAMLEVEL' => $spaminfo->{sa_score
},
166 'SPAMSTARS' => '*' x
(($spaminfo->{sa_score
} || 0) > 100 ?
100 : $spaminfo->{sa_score
} || 0),
167 'ADMIN' => $self->{pmg_cfg
}->get('admin', 'email'),
168 'HOST' => $msginfo->{hostname
},
169 'DOMAIN' => $msginfo->{domain
},
170 'FQDN' => $msginfo->{fqdn
},
171 'MSGID' => $queue->{msgid
},
172 'VERSION' => PMG
::pmgcfg
::package() . "/" . PMG
::pmgcfg
::version
() . "/" . PMG
::pmgcfg
::repoid
(),
175 $vars->{__spaminfo
} = $spaminfo;
178 if ($queue->{vinfo_clam
}) {
179 $vars->{'VIRUS_INFO'} = "Virus Info:";
180 $vars->{'VIRUS_INFO'} .= " clam: $queue->{vinfo_clam}" if $queue->{vinfo_clam
};
182 $vars->{'VIRUS_INFO'} = '';
185 if ($queue->{vinfo
}) {
186 $vars->{'VIRUS_INFO'} = "Virus Info: $queue->{vinfo}\n";
188 $vars->{'VIRUS_INFO'} = '';
192 $vars->{'SPAM_HITS'} = $spaminfo->{sa_hits
};
194 $vars->{'SPAM_INFO'} = '';
195 my $sscores = $spaminfo->{sa_data
};
197 if (defined ($sscores) && @$sscores != -1) {
200 $sa_text = "Spam detection results: 100\n";
202 $sa_text = "Spam detection results: $spaminfo->{sa_score}\n";
205 foreach my $s (@$sscores) {
207 $sa_text .= sprintf ("%-22s %6s %s\n", $s->{rule
},
208 1, $s->{desc
} || '-');
210 $sa_text .= sprintf ("%-22s %6s %s\n", $s->{rule
},
211 $s->{score
}, $s->{desc
} || '-');
214 $vars->{'SPAM_INFO'} = $sa_text;
218 delete ($vars->{'ADMIN'});
219 #delete ($vars->{'SPAM_INFO'});
226 my ($self, $queue, $msginfo, $entity, $ldap) = @_;
232 my $matching_rules = [];
234 my $rulecache = $self->{rulecache
};
235 my $rules = $rulecache->rules ();
236 my $dbh = $self->{ruledb
}->{dbh
};
238 # first, we remove all conditional written 'X-' header attributes
239 foreach my $rule (@$rules) {
240 next if !$rule->{active
};
241 next if ($rule->{direction
} == 0) && $msginfo->{trusted
};
242 next if ($rule->{direction
} == 1) && !$msginfo->{trusted
};
244 my $actions = $rulecache->get_actions ($rule->{id
});
246 foreach my $action (@$actions) {
247 if ($action->isa ("PMG::RuleDB::ModField")) {
248 my $fname = $action->{field
};
249 next if $fname !~ m/^X-/i;
250 $entity->head->delete($fname);
256 foreach my $rule (@$rules) {
257 next if !$rule->{active
};
258 next if ($rule->{direction
} == 0) && $msginfo->{trusted
};
259 next if ($rule->{direction
} == 1) && !$msginfo->{trusted
};
261 # match from, when and what classes (not target dependent)
262 if (!($rulecache->from_match ($rule->{id
}, $msginfo->{sender
}, $msginfo->{xforward
}->{addr
}, $ldap) &&
263 $rulecache->when_match ($rule->{id
}, time))) {
267 $rule_marks{$rule->{id
}} =
268 $rulecache->what_match ($rule->{id
}, $queue, $entity, $msginfo, $dbh);
270 $rule_actions{$rule->{id
}} = $rulecache->get_actions ($rule->{id
});
271 my $fin = $rulecache->final ($rule->{id
});
274 foreach my $target (@{$msginfo->{targets
}}) {
275 next if $final->{$target};
276 next if !defined ($rule_marks{$rule->{id
}});
277 next if !defined ($rule_marks{$rule->{id
}}->{$target});
278 next if !defined ($rule_marks{$rule->{id
}}->{$target}->{marks
});
279 next if !$rulecache->to_match ($rule->{id
}, $target, $ldap);
281 $final->{$target} = $fin;
283 push @{$rule_targets{$rule->{id
}}}, $target;
287 # Compute rule_info (summary about matching rule)
288 # this can be used for debugging
290 foreach my $rule (@$rules) {
291 next if !$rule_targets{$rule->{id
}};
293 push @$matching_rules, $rule->{id
};
295 $rule_info .= "Rule: $rule->{name}\n";
297 foreach my $target (@{$rule_targets{$rule->{id
}}}) {
298 $rule_info .= " Receiver: $target\n";
300 foreach my $action (@{$rule_actions{$rule->{id
}}}) {
301 $rule_info .= " Action: " . $action->short_desc () . "\n";
305 $msginfo->{rule_info
} = $rule_info;
307 if ($msginfo->{testmode
}) {
308 my $vars = $self->get_prox_vars($queue, $entity, $msginfo, undef, [], undef);
309 my $fh = $msginfo->{test_fh
};
310 print $fh $rule_info;
315 my $mod_group = PMG
::ModGroup-
>new($entity, $msginfo->{targets
});
317 foreach my $rule (@$rules) {
318 my $targets = $rule_targets{$rule->{id
}};
322 foreach my $t (@$targets) {
323 if ($rule_marks{$rule->{id
}}->{$t} && $rule_marks{$rule->{id
}}->{$t}->{spaminfo
}) {
324 $spaminfo = $rule_marks{$rule->{id
}}->{$t}->{spaminfo
};
325 # we assume spam info is the same for all matching targets
330 my $vars = $self->get_prox_vars ($queue, $entity, $msginfo, $rule,
331 $rule_targets{$rule->{id
}}, $spaminfo);
335 sort {$a->priority <=> $b->priority} @{$rule_actions{$rule->{id
}}};
337 foreach my $action (@sorted_actions) {
338 $action->execute ($queue, $self->{ruledb
}, $mod_group,
339 $rule_targets{$rule->{id
}},
340 $msginfo, $vars, $rule_marks{$rule->{id
}}->{marks
}, $ldap);
341 last if $action->final;
345 # we deliver all mail not matched by any rule
346 # (default action = accept)
348 foreach my $target (@{$msginfo->{targets
}}) {
349 next if $final->{$target};
351 push @$unmatched, $target;
355 my $accept = PMG
::RuleDB
::Accept-
>new ();
356 $accept->execute ($queue, $self->{ruledb
}, $mod_group, $unmatched,
357 $msginfo, undef, undef, undef);
360 return $matching_rules;
363 # reload ruledb and pmg config
366 my $prop = $self->{server
};
368 if ($self->{ruledb
}) {
369 $self->log (0, "reloading configuration $database");
370 $self->{ruledb
}->close ();
373 $self->{pmg_cfg
} = PMG
::Config-
>new();
374 $self->{cinfo
} = PVE
::INotify
::read_file
("cluster.conf");
377 my $dbh = PMG
::DBTools
::open_ruledb
($database);
378 $self->{ruledb
} = PMG
::RuleDB-
>new ($dbh);
381 $self->{rulecache
} = PMG
::RuleCache-
>new ($self->{ruledb
});
387 sleep (10); # reduce restart rate when postgres is down
392 my $ldapconf = PVE
::INotify
::read_file
('pmg-ldap.conf');
393 $self->{ldap
} = PMG
::LDAPSet-
>new_from_ldap_cfg($ldapconf, 1);
395 $self->{reload_config
} = 0;
407 my ($self, $level, $msg, @therest) = @_;
408 my $prop = $self->{server
};
410 return if $level =~ /^\d+$/ && $level > $prop->{log_level
};
412 $level = $syslog_map->{$level} || $level;
414 syslog
($level, $msg, @therest);
416 syslog
($level, $msg);
422 my $prop = $self->{server
};
424 $prop->{log_level
} = 3;
426 $self->log (0, "Filter daemon (re)started (max. $max_servers processes)");
428 eval { PMG
::MailQueue
::cleanup_active
(); };
429 $self->log (0, "Cleanup failures: $@") if $@;
431 my $sig_set = POSIX
::SigSet-
>new;
432 $sig_set->addset (&POSIX
::SIGHUP
);
433 $sig_set->addset (&POSIX
::SIGCHLD
);
434 my $old_sig_set = POSIX
::SigSet-
>new();
436 sigprocmask
(SIG_UNBLOCK
, $sig_set, $old_sig_set);
438 my ($backup_umask) = umask;
440 my $pmg_cfg = PMG
::Config-
>new();
442 # Note: you need to restart the daemon when you change 'rbl_checks'
443 my $rbl_checks = $pmg_cfg->get('spam', 'rbl_checks');
445 $self->{sa
} = Mail
::SpamAssassin-
>new ({
447 local_tests_only
=> $opt_testmode || !$rbl_checks,
448 home_dir_for_helpers
=> '/root',
449 userstate_dir
=> '/root/.spamassassin',
450 dont_copy_prefs
=> 1,
451 stop_at_threshold
=> 0,
454 $self->{sa
}->compile_now;
456 alarm (0); # SA forgets to clear alarm in some cases
457 umask ($backup_umask);
458 initlog
($prog_name, 'mail');
461 # reloading server configuration
462 if (defined $prop->{children
}) {
463 foreach my $pid (keys %{$prop->{children
}}) {
464 kill (10, $pid); # SIGUSR1 childs
470 sub child_init_hook
{
473 $0 = "$prog_name child";
475 # $self->log (3, "init child");
478 $self->load_config ();
483 $self->child_finish_hook;
488 $self->{reload_config
} = 1;
492 sub child_finish_hook
{
495 # $self->log (3, "finish child");
496 $self->{ruledb
}->close () if $self->{ruledb
};
499 my $last_dequeue_time = 0;
506 # do database maintainance here
509 my $tdiff = $ctime - $last_dequeue_time;
510 $last_dequeue_time = $ctime;
513 PMG
::Utils
::update_node_status_rrd
();
516 $self->log(0, PMG
::Utils
::msgquote
("ERROR: $err"));
520 return if $tdiff < 2*60;
522 $self->log (2, "starting database maintainance");
524 my ($csec, $usec) = gettimeofday
();
526 my $cinfo = PVE
::INotify
::read_file
("cluster.conf");
531 $dbh = PMG
::DBTools
::open_ruledb
($database);
534 $self->log (0, PMG
::Utils
::msgquote
("ERROR: $err"));
539 PMG
::Statistic
::update_stats
($dbh, $cinfo);
543 my ($csec_end, $usec_end) = gettimeofday
();
544 my $ptime = int (($csec_end-$csec)*1000 + ($usec_end - $usec)/1000);
547 $self->log (0, PMG
::Utils
::msgquote
($err));
549 $self->log (2, "end database maintainance ($ptime ms)");
552 $dbh->disconnect() if $dbh;
557 my ($self, $unpack, $entity, $msginfo, $queue) = @_;
562 if (($magic = $entity->{PMX_magic_ct
}) &&
563 ($path = $entity->{PMX_decoded_path
})) {
565 my $filename = basename
($path);
567 if (PMG
::Unpack
::is_archive
($magic)) {
568 $self->log (3, "$queue->{logid}: found archive '$filename' ($magic)");
570 my $start = [gettimeofday
];
572 $unpack->{mime
} = {};
575 $unpack->unpack_archive ($path, $magic);
578 $self->log (3, "$queue->{logid}: unpack failed - $@") if $@;
580 $entity->{PMX_content_types
} = $unpack->{mime
};
583 my $types = join (", ", sort keys (%{$entity->{PMX_content_types
}}));
584 my $fh = $msginfo->{test_fh
};
585 $filename =~ s/\d+/X/g if $filename =~ m/^msg-\d+-\d+.msg/;
586 print $fh "Types:$filename: $types\n" if $types;
589 my $elapsed = int(tv_interval
($start) * 1000);
591 $self->log (3, "$queue->{logid}: unpack archive '$filename' done ($elapsed ms)");
595 foreach my $part ($entity->parts) {
596 $self->unpack_entity ($unpack, $part, $msginfo, $queue);
602 my ($self, $smtp) = @_;
604 my ($csec, $usec) = gettimeofday
();
608 my $pmg_cfg = $self->{pmg_cfg
};
609 my $ldap = $self->{ldap
};
610 my $cinfo = $self->{cinfo
};
611 my $lcid = $cinfo->{local}->{cid
};
613 $msginfo->{test_fh
} = PMG
::AtomicFile-
>new("testresult.out", "w")
616 $msginfo->{trusted
} = $self->{trusted
};
619 # PHASE 1 - save incoming mail (already done)
622 $queue = $smtp->{queue
};
623 $queue->{sa
} = $self->{sa
};
625 $queue->{lic_valid
} = 1;
630 $msginfo->{testmode
} = $opt_testmode;
631 $msginfo->{sender
} = $smtp->{from
};
632 $msginfo->{xforward
} = $smtp->{xforward
};
633 $msginfo->{targets
} = $smtp->{to
};
635 $msginfo->{hostname
} = PVE
::INotify
::nodename
();
636 my $resolv = PVE
::INotify
::read_file
('resolvconf');
638 $msginfo->{domain
} = $resolv->{search
};
639 $msginfo->{fqdn
} = "$msginfo->{hostname}.$msginfo->{domain}";
640 $msginfo->{lcid
} = $lcid;
642 # $msginfo->{targets} is case sensitive,
643 # but pmail is always lower case!
645 foreach my $t (@{$msginfo->{targets
}}) {
647 if ($ldap && ($res = $ldap->account_info ($t))) {
648 $msginfo->{pmail
}->{$t} = $res->{pmail
};
650 $msginfo->{pmail
}->{$t} = lc ($t);
654 # PHASE 2 - parse mail
657 my $maxfiles = $pmg_cfg->get('clamav', 'archivemaxfiles');
659 my $entity = $queue->parse_mail($maxfiles);
661 $self->log (3, "$queue->{logid}: new mail message-id=%s", $queue->{msgid
});
663 # PHASE 3 - run external content analyzers
664 # (SPAM analyzer is run on demand later)
665 # on error: log error messages
668 # test for virus first
669 $queue->{vinfo
} = PMG
::Utils
::analyze_virus
(
670 $queue, $queue->{dataname
}, $pmg_cfg, $opt_testmode);
672 # always add this headers to incoming mails
673 # to enable user to report false negatives
674 if (!$msginfo->{trusted
}) {
675 if ($queue->{vinfo
}) {
676 $entity->head->replace('X-Proxmox-VInfo', $queue->{vinfo
});
680 # we unpack after virus scanning, because this is more secure.
681 # This way virus scanners gets the whole mail files and are able
682 # to detect phishing signature for example - which would not work
683 # if we decompose first and only analyze the decomposed attachments.
684 # Disadvantage is that we need to unpack more than
685 # once (bad performance).
687 # should we scan content types inside archives
689 my $rulecache = $self->{rulecache
};
691 my $scan_archives = 0;
693 if (($rulecache->{archivefilter_in
} && !$msginfo->{trusted
}) ||
694 ($rulecache->{archivefilter_out
} && $msginfo->{trusted
})) {
698 if ($scan_archives && !$queue->{vinfo
}) {
700 # unpack all archives - determine contained content types
702 my $decdir = $queue->{dumpdir
} . "/__decoded_archives";
705 my $start = [gettimeofday
];
710 # limits: We use clamav limit for maxfiles, and scan
711 # only 4 levels, timeout of 30 seconds
713 $unpack = PMG
::Unpack-
>new (
716 ctonly
=> 1, # only detect CTs
718 maxfiles
=> $maxfiles);
720 $self->unpack_entity ($unpack, $entity, $msginfo, $queue);
725 $unpack->cleanup() if $unpack;
727 my $elapsed = int(tv_interval
($start) * 1000);
730 $self->log (3, "$queue->{logid}: unpack archive failed ($elapsed ms) - $err");
734 # PHASE 4 - apply rules
735 # on error: exit (cleanup process should do the rest)
736 $msginfo->{maxspamsize
} = $pmg_cfg->get('spam', 'maxspamsize');
737 if ($msginfo->{maxspamsize
} <= 1024*64) {
738 $msginfo->{maxspamsize
} = 1024*64;
741 if ($msginfo->{trusted
}) {
742 my $hide = $pmg_cfg->get('mail', 'hide_received');
743 $entity->head->delete("Received") if $hide;
746 $matching_rules = $self->apply_rules($queue, $msginfo, $entity, $ldap);
751 $self->{errors
} = $queue->{errors
};
754 $self->{errors
} = 1 if $err;
760 my ($csec_end, $usec_end) = gettimeofday
();
762 int (($csec_end-$csec)*1000 + ($usec_end - $usec)/1000);
764 # PHASE 5 - log statistics
765 # on error: log error messages
768 my $dbh = $self->{ruledb
}->{dbh
};
770 foreach my $rid (@$matching_rules) {
771 $where .= $where ?
" OR ID = $rid" : "ID = $rid";
774 $dbh->do ("UPDATE Rule " .
775 "SET Count = Count + 1 " .
779 my $insert_cmds = "SELECT nextval ('cstatistic_id_seq');INSERT INTO CStatistic " .
780 "(CID, RID, ID, Time, Bytes, Direction, Spamlevel, VirusInfo, PTime, Sender) VALUES (" .
781 "$lcid, currval ('cstatistic_id_seq'), currval ('cstatistic_id_seq'),";
783 $insert_cmds .= $queue->{rtime
} . ',';
784 $insert_cmds .= $queue->{bytes
} . ',';
785 $insert_cmds .= $dbh->quote ($msginfo->{trusted
} ?
0 : 1) . ',';
786 $insert_cmds .= ($queue->{sa_score
} || 0) . ',';
787 $insert_cmds .= $dbh->quote ($queue->{vinfo
}) . ',';
788 $insert_cmds .= $time_total . ',';
789 $insert_cmds .= $dbh->quote ($msginfo->{sender
}) . ');';
791 foreach my $r (@{$msginfo->{targets
}}) {
792 my $tmp = $dbh->quote ($r);
793 my $blocked = $queue->{status
}->{$r} eq 'blocked' ?
1 : 0;
794 $insert_cmds .= "INSERT INTO CReceivers (CStatistic_CID, CStatistic_RID, Receiver, Blocked) " .
795 "VALUES ($lcid, currval ('cstatistic_id_seq'), $tmp, '$blocked'); ";
798 $dbh->do ($insert_cmds);
801 # save $err (because log clears $@)
804 $time_total = $time_total/1000;
806 my $ptspam = ($queue->{ptime_spam
} || 0)/1000;
807 my $ptclam = ($queue->{ptime_clam
} || 0)/1000;
809 $self->log (3, "$queue->{logid}: processing time: ${time_total} seconds ($ptspam, $ptclam)");
811 $msginfo->{test_fh
}->close if $opt_testmode;
817 sub process_request
{
819 my $prop = $self->{server
};
820 my $sock = $prop->{client
};
824 # make sure the ldap cache is up to date
825 $self->{ldap
}->update (1);
827 $self->load_config() if $self->{reload_config
};
829 $self->{trusted
} = 0;
830 if ($prop->{sockport
} == $opt_int_port && !$opt_untrusted) {
831 $self->{trusted
} = 1;
834 my $smtp = PMG
::SMTP-
>new ($sock);
836 my $maxcount = $max_requests - $prop->{requests
};
838 my $count = $smtp->loop (\
&handle_smtp
, $self, $maxcount);
840 $prop->{requests
} += $count - 1;
846 $self->log (0, $err) if $err;
848 kill(15, $prop->{ppid
}) if $opt_testmode;
850 my $mem = PVE
::ProcFSTools
::read_memory_usage
();
853 $self->log (0, "memory usage: $mem->{size} bytes");
855 if ($self->{errors
}) {
856 $self->log (0, "fast exit because of errors (free $mem->{size} bytes)");
858 } elsif ($mem->{size
} > (400*1024*1024)) {
859 $self->log (0, "fast exit to reduce server load (free $mem->{size} bytes)");
864 $self->done (1) if $err;
867 # test sig_hup with: for ((;;)) ;do kill -HUP `cat /var/run/${prog_name}.pid`; done;
868 # wrapper to avoid multiple calls to sig_hup
871 my $prop = $self->{server
};
873 return if defined ($prop->{_HUP
}); # do not call twice
875 $self->SUPER::sig_hup
();
878 sub restart_close_hook
{
881 my $sig_set = POSIX
::SigSet-
>new;
882 $sig_set->addset (&POSIX
::SIGHUP
);
883 $sig_set->addset (&POSIX
::SIGCHLD
); # to avoid zombies
884 my $old_sig_set = POSIX
::SigSet-
>new();
886 sigprocmask
(SIG_BLOCK
, $sig_set, $old_sig_set);
889 sub pre_server_close_hook
{
891 my $prop = $self->{server
};
893 if (defined $prop->{_HUP
}) {
894 undef $prop->{pid_file_unlink
};
897 if (defined $prop->{children
}) {
898 foreach my $pid (keys %{$prop->{children
}}) {
899 kill (1, $pid); # HUP childs
903 # nicely shutdown childs (give them max 30 seconds to shut down)
904 my $previous_alarm = alarm(30);
906 local $SIG{ALRM
} = sub { die "Timed Out!\n" };
909 1 while ((($pid = waitpid (-1, 0)) > 0) || ($! == EINTR
));
911 alarm(0); # avoid race
913 alarm ($previous_alarm);
916 # initialize mime system before fork
917 xdg_mime_get_mime_type_for_file
($0);
920 server
=> $server_attr,
923 if (!$opt_testmode) {
930 my $sender ='sender@proxtest.com';
931 my $targets = ['target1@proxtest.com',
932 'target2@proxtest.com',
933 'target3@proxtest.com'];
937 $smtp = Net
::SMTP-
>new ('127.0.0.1', Port
=> 10023);
942 # syslog ('info', "connected to " . $smtp->domain);
944 $smtp->mail ($sender);
945 $smtp->to (@$targets);
949 open (TMP
, $opt_testmode) ||
950 die "unable to upen file '$opt_testmode' - $! :ERROR";
952 $smtp->datasend ($_);
956 $smtp->datasend ("\n");
969 pmg-smtp-filter - the Proxmox mail filter
973 pmg-smtp-filter [-u] [-t testfile]
977 Documentation is available at www.proxmox.com