This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
faq:sendmail_tip [2009/03/07 03:02] 202.89.166.33 |
faq:sendmail_tip [2014/06/28 00:57] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== QUESTION Sendmail and Exchange server 2007 ====== | ||
| + | |||
| + | Answer: use authenticated smtp and give the use account rights to forward emails as anyone | ||
| + | |||
| + | -- | ||
| + | |||
| + | By default exchange server 2007 will not allow smtp mail to be relayed by anonymouse SMTP sessions, and it restricts the sending FROM address so you cant just spoof any email address you want. All good ideas but if you have linux servers running sendmail (REDHAT ENTERPRISE and CENTOS in our case) you may want to be able to send reporting emails from daemons and cron jobs. | ||
| + | |||
| + | To fix that the best way is to use access options to authenticate against the exchange server. | ||
| + | |||
| + | Make sure at least these options are on in your sendmail.mc, this was on a server that ONLY sends email, it never recieves any. | ||
| + | |||
| + | remake the sendmail.cf using m4 | ||
| + | <code> | ||
| + | cd /etc/mail | ||
| + | m4 sendmail.mc > sendmail.cf | ||
| + | service sendmail restart | ||
| + | </code> | ||
| + | |||
| + | <file> | ||
| + | define(`SMART_HOST', `smartsmtpserver.mydomain.local')dnl | ||
| + | define(`ALIAS_FILE', `/etc/aliases')dnl | ||
| + | define(`confAUTH_OPTIONS', `A')dnl | ||
| + | TRUST_AUTH_MECH(`EXTERNAL LOGIN PLAIN')dnl | ||
| + | define(`confAUTH_MECHANISMS', `EXTERNAL LOGIN PLAIN')dnl | ||
| + | FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl | ||
| + | FEATURE(`genericstable', `hash -o /etc/mail/genericstable.db')dnl | ||
| + | GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain') | ||
| + | FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl | ||
| + | FEATURE(redirect)dnl | ||
| + | FEATURE(always_add_domain)dnl | ||
| + | FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl | ||
| + | LOCAL_DOMAIN(`mydomain.local')dnl | ||
| + | MASQUERADE_AS(`externaldomain.external.com)dnl | ||
| + | FEATURE(masquerade_envelope)dnl | ||
| + | FEATURE(masquerade_entire_domain)dnl | ||
| + | MASQUERADE_DOMAIN(localhost)dnl | ||
| + | MASQUERADE_DOMAIN(localhost.localdomain)dnl | ||
| + | MASQUERADE_DOMAIN(mydomain.local)dnl | ||
| + | MASQUERADE_DOMAIN(MYSERVER.MYDOMAIN.LOCAL)dnl | ||
| + | </file> | ||
| + | |||
| + | the access file contains the usernames and passwords for each server you are sending to. | ||
| + | |||
| + | /etc/mail/access | ||
| + | <file> | ||
| + | # Check the /usr/share/doc/sendmail/README.cf file for a description | ||
| + | # of the format of this file. (search for access_db in that file) | ||
| + | # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc | ||
| + | # package. | ||
| + | # | ||
| + | # by default we allow relaying from localhost... | ||
| + | Connect:localhost.localdomain RELAY | ||
| + | Connect:localhost RELAY | ||
| + | Connect:127.0.0.1 RELAY | ||
| + | AuthInfo:smartsmtpserver.mydomain.local "U:username" "I:username" "P:password" "M:LOGIN" | ||
| + | </file> | ||
| + | |||
| + | define the addresses senders will be given - as the daemons that send messages need to be unique accross the domain, we dont want them all coming from root@... | ||
| + | |||
| + | /etc/mail/genericstable | ||
| + | |||
| + | <file> | ||
| + | root thisserversroot@myexternaldomain.external.com | ||
| + | </file> | ||
| + | |||
| + | the name of the senders domains that will be translated | ||
| + | |||
| + | /etc/mail/genericsdomain | ||
| + | |||
| + | <file> | ||
| + | THISSERVER.MYDOMAIN.LOCAL | ||
| + | </file> | ||
| + | |||
| + | NOW on the exchange server side you either need to give someone that email address (thisserversroot@myexternaldomain.external.com) | ||
| + | |||
| + | or do this in the exchange shell - this allows the user to send as "anyone" | ||
| + | |||
| + | |||
| + | add-adpermission 'Default connector name on exchange server' -User 'username' -ExtendedRights ms-Exch-SMTP-Accept-Authoritative-Domain-Sender | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ====== Question:Root email not masqueraded by Sendmail ====== | ||
| + | |||
| + | Answer: Remove root as an exposed user. | ||
| + | |||
| + | ===== Sendmail Problems ===== | ||
| + | |||
| + | I have used sendmail of and on for a few years but still struggle with it at times. | ||
| + | |||
| + | Recently I ran into the problem that even though masquerading is on in the sendmail config by default the root email address is not changed to be a DNS registered address but instead left in the form of root@hostname.dnsname.com rather than root@dnsname.com | ||
| + | |||
| + | This only became a problem because some email servers (my ISP's one) as a means of filtering out junk mail refuse to accept emails from unresolvable domains. | ||
| + | |||
| + | the sendmail.mf line that was relevant is | ||
| + | |||
| + | EXPOSED_USER(`root')dnl | ||
| + | |||
| + | By removing (commenting it out) as in | ||
| + | |||
| + | dnl EXPOSED_USER(`root')dnl | ||
| + | |||
| + | Then root email is masqueraded like all other outgoing emails. | ||
| + | |||
| + | |||
| + | ===== sendmail log analysis ===== | ||
| + | http://www.reedmedia.net/software/sendmail_stats/sendmail_stats.0.07.txt | ||
| + | |||
| + | |||
| + | <code perl> | ||
| + | #!/usr/bin/perl | ||
| + | |||
| + | # works with perl 4 | ||
| + | |||
| + | # sendmail_stats Version 0.07 | ||
| + | # (c) 2001 Jeremy C. Reed | ||
| + | # this is free, but use at your own risk | ||
| + | |||
| + | ## still needs a lot of work; it is probably only 10 percent finished | ||
| + | ## and about 90 percent of this code needs to be rewritten. | ||
| + | |||
| + | # use like in your crontab: | ||
| + | #30 5 * * * nobody /usr/contrib/bin/gunzip -c /var/log/maillog.0.gz |\ | ||
| + | # /usr/local/bin/sendmail_stats | /usr/bin/mail -s "sendmail stats" postmaster | ||
| + | |||
| + | #for appending "@" and host name | ||
| + | $default_hostname = 'EDIT-THIS-default-domain.net'; | ||
| + | |||
| + | $top_amt = 20; | ||
| + | |||
| + | ## MAIN routine | ||
| + | |||
| + | while ($line = <>) { | ||
| + | |||
| + | if ($line =~ | ||
| + | /^(\w+)\s+(\d+)\s(\d+):(\d+:\d+)\s+(\w+)\s+(\w+)\[(\d+)\]:\s(\w+\d+):\s(.+)$/) { | ||
| + | |||
| + | $month = $1; | ||
| + | $day = $2; | ||
| + | $hour = $3; | ||
| + | $min_sec = $4; | ||
| + | $user = $5; | ||
| + | $daemon = $6; | ||
| + | $pid = $7; | ||
| + | $id = $8; | ||
| + | $data = $9; | ||
| + | |||
| + | # get log start time | ||
| + | if (! $log_start_time) { $log_start_time = "$month $day $hour $min_sec"; } | ||
| + | |||
| + | if ($daemon eq 'sendmail') { | ||
| + | |||
| + | if ($data =~ /from=(.+),\ssize=/) { | ||
| + | $from = $1; | ||
| + | $from =~ s/[><]//g; | ||
| + | if ($from eq "") { # from a Mailer-Daemon | ||
| + | $from = "<>"; | ||
| + | } | ||
| + | |||
| + | $senders{$from}++; | ||
| + | |||
| + | if ($data =~ / size=(\d+)\,\s/) { | ||
| + | $size = $1; | ||
| + | $sizes{$id} += $size; | ||
| + | $total_size += $size; | ||
| + | } | ||
| + | #$from_count++; | ||
| + | |||
| + | if ($data =~ / relay=(.+)[$:]/) { | ||
| + | $relay = $1; | ||
| + | if ($relay =~ /may be/) { $relay =~ s/(.*) \(may be/$1/; } | ||
| + | $sending_hosts{$relay}++; | ||
| + | } | ||
| + | |||
| + | } # from= | ||
| + | elsif (($data =~ /to=(.+)\, ctladdr=(.+), delay=/) || | ||
| + | ($data =~ /to=(.+)\, delay=/)) { | ||
| + | $to = $1; | ||
| + | if ($2) { | ||
| + | $to = $2; | ||
| + | $to =~ s/ \(\d+\/\d+\)//g; | ||
| + | } | ||
| + | |||
| + | if ($data =~ / stat=([^ ]+)/) { | ||
| + | $stat = $1; | ||
| + | } | ||
| + | |||
| + | if ($stat eq "Sent") { | ||
| + | #here | ||
| + | if ($data =~ / mailer=([^,]+)\,\s/) { | ||
| + | $mailer = $1; | ||
| + | |||
| + | if ($mailer eq "local" || $mailer eq "prog" || | ||
| + | $mailer eq "virtual" || $mailer eq "*file*") { | ||
| + | |||
| + | $local_size += $sizes{$id}; | ||
| + | delete ($sizes{$id}); | ||
| + | $received_messages++; | ||
| + | $to =~ s/[<"](.+)[>"]/$1/; | ||
| + | if ($to =~ /\,/) { | ||
| + | foreach $username (split (/\,/, $to)) { | ||
| + | $username = $username . '@' . $default_hostname; | ||
| + | $local_deliveries{$username}++; | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | $local_deliveries{$to}++; | ||
| + | } | ||
| + | } # a local delivery | ||
| + | elsif ($mailer =~ /smtp/i) { | ||
| + | $sent_messages++; | ||
| + | |||
| + | if ($data =~ / relay=([^,]+),\s.+$/) { | ||
| + | $relay = $1; | ||
| + | $destination_hosts{$relay}++; | ||
| + | } | ||
| + | |||
| + | } # sent out | ||
| + | |||
| + | } # mailer= | ||
| + | |||
| + | $hours{$hour}++; | ||
| + | |||
| + | } # stat is Sent | ||
| + | else { | ||
| + | $sending_problems++; | ||
| + | } | ||
| + | } # to= | ||
| + | |||
| + | # $months{$month}++; | ||
| + | # $days{$day}++; | ||
| + | # $total++; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # get log start time | ||
| + | $log_end_time = "$month $day $hour $min_sec"; | ||
| + | |||
| + | ## 1048576 is one meg | ||
| + | $total_size_mb = sprintf ("%.1f", ($total_size/1048576)); | ||
| + | $local_size_mb = sprintf ("%.1f", ($local_size/1048576)); | ||
| + | |||
| + | print <<END_OF_DATA; | ||
| + | Sendmail log analysis | ||
| + | |||
| + | Log starts at $log_start_time and ends at $log_end_time | ||
| + | |||
| + | Total bytes transferred: $total_size ($total_size_mb MB) | ||
| + | Total bytes In: $local_size ($local_size_mb MB) | ||
| + | Messages Out: $sent_messages | ||
| + | Messages In: $received_messages | ||
| + | Sending Problems: $sending_problems | ||
| + | |||
| + | END_OF_DATA | ||
| + | |||
| + | #print "from_count $from_count\n"; | ||
| + | |||
| + | $max = 0; | ||
| + | for ($c = 0; $c < 24; $c++) { | ||
| + | if ($c < 10) { $i = "0$c"; } | ||
| + | else { $i = $c; } | ||
| + | if ($hours{$i} > $max) { $max = $hours{$i}; } | ||
| + | } | ||
| + | |||
| + | $scale = int($max/50); | ||
| + | $scale = 1 if $scale == 0; | ||
| + | |||
| + | print "Messages per hour (each dot is $scale messages)\n________________\n"; | ||
| + | |||
| + | for ($c = 0; $c < 24; $c++) { | ||
| + | if ($c < 10) { $i = "0$c"; } | ||
| + | else { $i = $c; } | ||
| + | printf("%3d: %6d %s\n", $i, $hours{$i}, "." x int($hours{$i}/$scale)); | ||
| + | } | ||
| + | |||
| + | &show_sending_hosts; | ||
| + | &show_destination_hosts; | ||
| + | &show_local_deliveries; | ||
| + | &show_senders; | ||
| + | |||
| + | print "\n"; | ||
| + | |||
| + | ## end | ||
| + | |||
| + | sub show_sending_hosts { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Sending Hosts\n____________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $sending_hosts{$b} <=> $sending_hosts{$a} } | ||
| + | keys %sending_hosts) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$sending_hosts{$key}\t$key\n"; | ||
| + | } | ||
| + | $total_sending_hosts++; | ||
| + | $total_sending_host_messages += $sending_hosts{$key}; | ||
| + | } | ||
| + | |||
| + | print "\n$total_sending_hosts sending hosts attempted $total_sending_host_messages messages\n"; | ||
| + | } # show_sending_hosts | ||
| + | |||
| + | sub show_destination_hosts { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Destination Hosts\n________________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $destination_hosts{$b} <=> $destination_hosts{$a} } | ||
| + | keys %destination_hosts) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$destination_hosts{$key}\t$key\n"; | ||
| + | } | ||
| + | $total_destination_hosts++; | ||
| + | $total_destination_host_messages += $destination_hosts{$key}; | ||
| + | } | ||
| + | |||
| + | print "\n$total_destination_hosts destination hosts received $total_destination_host_messages messages\n"; | ||
| + | |||
| + | } # show_destination_hosts | ||
| + | |||
| + | sub show_local_deliveries { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Local Deliveries\n_______________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $local_deliveries{$b} <=> $local_deliveries{$a} } | ||
| + | keys %local_deliveries) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$local_deliveries{$key}\t$key\n"; | ||
| + | } | ||
| + | $local_accounts++; | ||
| + | $total_local_messages += $local_deliveries{$key}; | ||
| + | } | ||
| + | |||
| + | "\n$local_accounts local accounts received mail ($total_local_messages messages combined).\n"; | ||
| + | |||
| + | } # show_local_deliveries | ||
| + | |||
| + | sub show_senders { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Senders\n______________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $senders{$b} <=> $senders{$a} } | ||
| + | keys %senders) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$senders{$key}\t$key\n"; | ||
| + | } | ||
| + | $total_senders++; | ||
| + | $total_senders_messages += $senders{$key}; | ||
| + | } | ||
| + | |||
| + | "\n$total_senders senders sent a combined $total_senders_messages messages.\n"; | ||
| + | |||
| + | } # show_senders | ||
| + | |||
| + | sub show_data { | ||
| + | |||
| + | print <<END_OF_DATA; | ||
| + | $month $day $hour $min_sec | ||
| + | $user $daemon | ||
| + | $pid pid | ||
| + | $id | ||
| + | $data | ||
| + | |||
| + | END_OF_DATA | ||
| + | |||
| + | } #show data | ||
| + | |||
| + | |||
| + | |||
| + | </code> | ||
| + | |||
| + | |||
| + | |||
| + | ====== new 1 ====== | ||
| + | <code perl> | ||
| + | #!/usr/bin/perl | ||
| + | |||
| + | # works with perl 4 | ||
| + | |||
| + | # sendmail_stats Version 0.07 | ||
| + | # (c) 2001 Jeremy C. Reed | ||
| + | # this is free, but use at your own risk | ||
| + | |||
| + | ## still needs a lot of work; it is probably only 10 percent finished ## and about 90 percent of this code needs to be rewritten. | ||
| + | |||
| + | # use like in your crontab: | ||
| + | #30 5 * * * nobody /usr/contrib/bin/gunzip -c /var/log/maillog.0.gz |\ | ||
| + | # /usr/local/bin/sendmail_stats | /usr/bin/mail -s "sendmail stats" postmaster | ||
| + | |||
| + | #for appending "@" and host name | ||
| + | $default_hostname = 'localhost'; | ||
| + | |||
| + | $top_amt = 50; | ||
| + | |||
| + | ## MAIN routine | ||
| + | |||
| + | while ($line = <>) { | ||
| + | |||
| + | if ($line =~ | ||
| + | /^(\w+)\s+(\d+)\s(\d+):(\d+:\d+)\s+(\w+)\s+(\w+)\[(\d+)\]:\s(\w+\d+):\s(.+)$/) { | ||
| + | |||
| + | $month = $1; | ||
| + | $day = $2; | ||
| + | $hour = $3; | ||
| + | $min_sec = $4; | ||
| + | $user = $5; | ||
| + | $daemon = $6; | ||
| + | $pid = $7; | ||
| + | $id = $8; | ||
| + | $data = $9; | ||
| + | |||
| + | # get log start time | ||
| + | if (! $log_start_time) { $log_start_time = "$month $day $hour $min_sec"; } | ||
| + | |||
| + | if ($daemon eq 'sendmail') { | ||
| + | |||
| + | if ($data =~ /from=(.+),\ssize=/) { | ||
| + | $from = $1; | ||
| + | $from =~ s/[><]//g; | ||
| + | if ($from eq "") { # from a Mailer-Daemon | ||
| + | $from = "<>"; | ||
| + | } | ||
| + | |||
| + | $senders{$from}++; | ||
| + | |||
| + | if ($data =~ / size=(\d+)\,\s/) { | ||
| + | $size = $1; | ||
| + | $sizes{$id} += $size; | ||
| + | $total_size += $size; | ||
| + | } | ||
| + | #$from_count++; | ||
| + | |||
| + | if ($data =~ / relay=(.+)[$:]/) { | ||
| + | $relay = $1; | ||
| + | if ($relay =~ /may be/) { $relay =~ s/(.*) \(may be/$1/; } | ||
| + | $sending_hosts{$relay}++; | ||
| + | } | ||
| + | |||
| + | } # from= | ||
| + | elsif (($data =~ /to=(.+)\, ctladdr=(.+), delay=/) || | ||
| + | ($data =~ /to=(.+)\, delay=/)) { | ||
| + | $to = $1; | ||
| + | if ($2) { | ||
| + | $to = $2; | ||
| + | $to =~ s/ \(\d+\/\d+\)//g; | ||
| + | } | ||
| + | |||
| + | if ($data =~ / stat=([^ ]+)/) { | ||
| + | $stat = $1; | ||
| + | } | ||
| + | |||
| + | if ($stat eq "Sent") { | ||
| + | #here | ||
| + | if ($data =~ / mailer=([^,]+)\,\s/) { | ||
| + | $mailer = $1; | ||
| + | |||
| + | if ($mailer eq "local" || $mailer eq "prog" || | ||
| + | $mailer eq "virtual" || $mailer eq "*file*") { | ||
| + | |||
| + | $local_size += $sizes{$id}; | ||
| + | delete ($sizes{$id}); | ||
| + | $received_messages++; | ||
| + | $to =~ s/[<"](.+)[>"]/$1/; | ||
| + | if ($to =~ /\,/) { | ||
| + | foreach $username (split (/\,/, $to)) { | ||
| + | $username = $username . '@' . $default_hostname; | ||
| + | $local_deliveries{$username}++; | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | $local_deliveries{$to}++; | ||
| + | } | ||
| + | } # a local delivery | ||
| + | elsif ($mailer =~ /smtp/i) { | ||
| + | $sent_messages++; | ||
| + | |||
| + | if ($data =~ / relay=([^,]+),\s.+$/) { | ||
| + | $relay = $1; | ||
| + | $destination_hosts{$relay}++; | ||
| + | |||
| + | $relayed_size += $sizes{$id}; | ||
| + | delete ($sizes{$id}); | ||
| + | $relayed_messages++; | ||
| + | $to =~ s/[<"](.+)[>"]/$1/; | ||
| + | if ($to =~ /\,/) { | ||
| + | foreach $username (split (/\,/, $to)) { | ||
| + | $relayed_deliveries{$username}++; | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | $relayed_deliveries{$to}++; | ||
| + | } | ||
| + | |||
| + | } # sent out | ||
| + | |||
| + | } # mailer= | ||
| + | |||
| + | $hours{$hour}++; | ||
| + | |||
| + | } # stat is Sent | ||
| + | else { | ||
| + | $sending_problems++; | ||
| + | } | ||
| + | } # to= | ||
| + | |||
| + | # $months{$month}++; | ||
| + | # $days{$day}++; | ||
| + | # $total++; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # get log start time | ||
| + | $log_end_time = "$month $day $hour $min_sec"; | ||
| + | |||
| + | ## 1048576 is one meg | ||
| + | $total_size_mb = sprintf ("%.1f", ($total_size/1048576)); $local_size_mb = sprintf ("%.1f", ($local_size/1048576)); $relayed_size = sprintf ("%.1f", ($relayed_size/1048576)); | ||
| + | |||
| + | print <<END_OF_DATA; | ||
| + | Sendmail log analysis | ||
| + | |||
| + | Log starts at $log_start_time and ends at $log_end_time | ||
| + | |||
| + | Total bytes transferred: $total_size ($total_size_mb MB) Total bytes In: $local_size ($local_size_mb MB) Messages Out: $sent_messages Messages In: $received_messages Sending Problems: $sending_problems | ||
| + | |||
| + | END_OF_DATA | ||
| + | |||
| + | #print "from_count $from_count\n"; | ||
| + | |||
| + | $max = 0; | ||
| + | for ($c = 0; $c < 24; $c++) { | ||
| + | if ($c < 10) { $i = "0$c"; } | ||
| + | else { $i = $c; } | ||
| + | if ($hours{$i} > $max) { $max = $hours{$i}; } } | ||
| + | |||
| + | $scale = int($max/50); | ||
| + | $scale = 1 if $scale == 0; | ||
| + | |||
| + | print "Messages per hour (each dot is $scale messages)\n________________\n"; | ||
| + | |||
| + | for ($c = 0; $c < 24; $c++) { | ||
| + | if ($c < 10) { $i = "0$c"; } | ||
| + | else { $i = $c; } | ||
| + | printf("%3d: %6d %s\n", $i, $hours{$i}, "." x int($hours{$i}/$scale)); } | ||
| + | |||
| + | &show_sending_hosts; | ||
| + | &show_destination_hosts; | ||
| + | &show_local_deliveries; | ||
| + | &show_relayed_deliveries; | ||
| + | &show_senders; | ||
| + | |||
| + | print "\n"; | ||
| + | |||
| + | ## end | ||
| + | |||
| + | sub show_sending_hosts { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Sending Hosts\n____________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $sending_hosts{$b} <=> $sending_hosts{$a} } | ||
| + | keys %sending_hosts) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$sending_hosts{$key}\t$key\n"; | ||
| + | } | ||
| + | $total_sending_hosts++; | ||
| + | $total_sending_host_messages += $sending_hosts{$key}; | ||
| + | } | ||
| + | |||
| + | print "\n$total_sending_hosts sending hosts attempted $total_sending_host_messages messages\n"; } # show_sending_hosts | ||
| + | |||
| + | sub show_destination_hosts { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Destination Hosts\n________________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $destination_hosts{$b} <=> $destination_hosts{$a} } | ||
| + | keys %destination_hosts) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$destination_hosts{$key}\t$key\n"; | ||
| + | } | ||
| + | $total_destination_hosts++; | ||
| + | $total_destination_host_messages += $destination_hosts{$key}; | ||
| + | } | ||
| + | |||
| + | print "\n$total_destination_hosts destination hosts received $total_destination_host_messages messages\n"; | ||
| + | |||
| + | } # show_destination_hosts | ||
| + | |||
| + | sub show_local_deliveries { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Local Deliveries\n_______________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $local_deliveries{$b} <=> $local_deliveries{$a} } | ||
| + | keys %local_deliveries) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$local_deliveries{$key}\t$key\n"; | ||
| + | } | ||
| + | $local_accounts++; | ||
| + | $total_local_messages += $local_deliveries{$key}; | ||
| + | } | ||
| + | |||
| + | "\n$local_accounts local accounts received mail ($total_local_messages messages combined).\n"; | ||
| + | |||
| + | } # show_local_deliveries | ||
| + | |||
| + | sub show_relayed_deliveries { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Relayed Deliveries\n_______________________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $relayed_deliveries{$b} <=> $relayed_deliveries{$a} } | ||
| + | keys %relayed_deliveries) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$relayed_deliveries{$key}\t$key\n"; | ||
| + | } | ||
| + | $relayed_accounts++; | ||
| + | $total_relayed_messages += $relayed_deliveries{$key}; | ||
| + | } | ||
| + | |||
| + | "\n$relayed_accounts relayed accounts received mail ($total_relayed_messages messages combined).\n"; | ||
| + | |||
| + | } # show_relayed_deliveries | ||
| + | |||
| + | sub show_senders { | ||
| + | $count = 0; | ||
| + | print "\nTop $top_amt Senders\n______________\n"; | ||
| + | |||
| + | foreach $key (sort { | ||
| + | $senders{$b} <=> $senders{$a} } | ||
| + | keys %senders) { | ||
| + | $count++; | ||
| + | if ($count <= $top_amt) { | ||
| + | print "$senders{$key}\t$key\n"; | ||
| + | } | ||
| + | $total_senders++; | ||
| + | $total_senders_messages += $senders{$key}; | ||
| + | } | ||
| + | |||
| + | "\n$total_senders senders sent a combined $total_senders_messages messages.\n"; | ||
| + | |||
| + | } # show_senders | ||
| + | |||
| + | sub show_data { | ||
| + | |||
| + | print <<END_OF_DATA; | ||
| + | $month $day $hour $min_sec | ||
| + | $user $daemon | ||
| + | $pid pid | ||
| + | $id | ||
| + | $data | ||
| + | |||
| + | END_OF_DATA | ||
| + | |||
| + | } #show data | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | </code> | ||