Mgolfieri- Admin notification emails: Difference between revisions
Line 93: | Line 93: | ||
A nice customer had an issue with a not-so-elastic 3rd party SMTP relay not allowing emails to come from a certain hostname, and this could not be customized due to certain constraints. This is the delivery failure notification being received: | A nice customer had an issue with a not-so-elastic 3rd party SMTP relay not allowing emails to come from a certain hostname, and this could not be customized due to certain constraints. This is the delivery failure notification being received: | ||
smtprelay.domain.com #<smtprelay.domain.com #5.0.0 smtp; 550-Verification failed for <zimbra@fqdn. | smtprelay.domain.com #<smtprelay.domain.com #5.0.0 smtp; 550-Verification failed for <zimbra@fqdn.zcs8-ga.cork.zimbralab.com> | ||
550-Unrouteable address 550 Sender verify failed> #SMTP# | 550-Unrouteable address 550 Sender verify failed> #SMTP# | ||
Line 106: | Line 106: | ||
[...] | [...] | ||
To workaround this and have the domain name as the real sender (not just the From: field) and make the 3rd party SMTP relay happy, edit the script ''/opt/zimbra/libexec/zmdailyreport'' so that you use another mail library “Net::SMTP” instead of “Mail::Mailer”. With that library, emails correctly appear to come from zimbra@domain.com. | To workaround this and have the domain name as the real sender domain for the zimbra user (not just the From: field) and make the 3rd party SMTP relay happy, edit the script ''/opt/zimbra/libexec/zmdailyreport'' so that you use another mail library “Net::SMTP” instead of “Mail::Mailer”. With that library, emails correctly appear to come from zimbra@domain.com. | ||
The change should be so that: | The change should be so that: |
Revision as of 14:36, 28 March 2013
Admin email notifications are mostly hot-changeable, they don't need any restart since they are handled by cronjobs on most cases, and settings are sourced at every run. For example:
Creating a local domain for system delivery
It is generally good practice to have a domain called as the zimbra server hostname itself. To find the zimbra hostname:
su - zimbra zmhostname
If you don't have it already created (it is the default when installing zimbra, unless you change the default options in the installer menu), then create it in the Admin Console, or:
su - zimbra zmprov cd `zmhostname`
MTA notifications
For any general SMTP-related notification, check:
zmlocalconfig smtp_destination
and if wrong, please change it via:
zmlocalconfig -e smtp_destination=admin@domain.com
For the AV notifications, check:
zmlocalconfig av_notify_user
and if wrong, please change it via:
zmlocalconfig -e av_notify_user=admin@domain.com
Backup reports
Regarding backup reports, check:
zimbra@zcs7-ga:~$ zmprov gacf zimbraBackupReportEmailRecipients zimbraBackupReportEmailRecipients: admin@domain.com
zimbra@zcs7-ga:~$ zmprov gs `zmhostname` zimbraBackupReportEmailRecipients # name zcs7-ga.cork.zimbralab.com zimbraBackupReportEmailRecipients: admin@domain.com
In case they are misconfigured, you can change by first issuing:
zmprov mcf zimbraBackupReportEmailRecipients admin@domain.com
Since server settings override global ones, check on every store node:
$ zmprov gs `zmhostname` zimbraBackupReportEmailRecipients
If the above will still report a wrong value, then:
$ zmprov ms `zmhostname` zimbraBackupReportEmailRecipients admin@domain.com
Note that the value is multi-valued:
<attr id="459" name="zimbraBackupReportEmailRecipients" type="string" cardinality="multi" optionalIn="globalConfig,server" flags="serverInherited"> <desc>Backup report email recipients</desc> </attr>
So if you want to add other email addresses, after setting the main one as per the instructions above, please do (note the plus sign, it's very important not to leave it out!):
$ zmprov mcf +zimbraBackupReportEmailRecipients another-admin@domain.com
and if you need this to be done on this server only instead of changing it globally:
$ zmprov ms `zmhostname` +zimbraBackupReportEmailRecipients another-admin@domain.com
Likewise, to remove an email address:
$ zmprov ms `zmhostname` -zimbraBackupReportEmailRecipients another-admin@domain.com
Regular notifications scheduling
Check that the cronjobs are set, and at what time they trigger. Usually the following are the default settings:
zimbra@zcs7-ga:~$ crontab -l |grep report 0 1 * * 6 /opt/zimbra/bin/zmbackup -f -a all --mail-report 0 1 * * 0-5 /opt/zimbra/bin/zmbackup -i --mail-report 0 0 * * * /opt/zimbra/bin/zmbackup -del 1m --mail-report 0 23 * * 7 /opt/zimbra/libexec/zmdbintegrityreport -m # Daily reports 30 23 * * * /opt/zimbra/libexec/zmdailyreport -m
According to the above times set, you can then check /var/log/zimbra.log accordingly to see if you find any error. You should see entries around this following line for example, coming from the server itself:
Nov 27 23:30:40 zcs7-ga postfix/qmgr[16654]: BF2B020832: from=<zimbra@zcs7-ga.cork.zimbralab.com>, size=4138, nrcpt=1 (queue active) [...] Nov 27 23:30:44 zcs7-ga postfix/lmtp[24064]: 8D50320834: to=<admin@zcs7.cork.zimbralab.com>, relay=zcs7-ga.cork.zimbralab.com[10.21.71.188]:7025, delay=0.18, delays=0.02/0.02/0.01/0.13, dsn=2.1.5, status=sent (250 2.1.5 Delivery OK)
Troubleshooting the zmdailyreport body content
If you get the emails, but you don't get a proper body content for some reason, manually triggering the commands you see in the crontab without the -m/--mail-report option will produce the same email content on the standard output, this might be useful for troubleshooting:
/opt/zimbra/libexec/zmdailyreport
As you can see, running the other commands seen in the crontab will trigger bigger operations (full/incremental backups, deletion, etc..) so pay extra attention to them should you need to run them for troubleshooting.
Changing the originating hostname
A nice customer had an issue with a not-so-elastic 3rd party SMTP relay not allowing emails to come from a certain hostname, and this could not be customized due to certain constraints. This is the delivery failure notification being received:
smtprelay.domain.com #<smtprelay.domain.com #5.0.0 smtp; 550-Verification failed for <zimbra@fqdn.zcs8-ga.cork.zimbralab.com> 550-Unrouteable address 550 Sender verify failed> #SMTP#
The hostname appears in the Received: from and other fields:
Return-Path: zimbra@zcs8-ga.cork.zimbralab.com Received: from zcs8-ga.cork.zimbralab.com (LHLO zcs8-ga.cork.zimbralab.com) (10.27.46.3) by zcs8-ga.cork.zimbralab.com with LMTP; Thu, 21 Mar 2013 [...] From: admin@domain.com Message-Id: <20130321101416.B0DFF21F7E0@zcs8-ga.cork.zimbralab.com> [...]
To workaround this and have the domain name as the real sender domain for the zimbra user (not just the From: field) and make the 3rd party SMTP relay happy, edit the script /opt/zimbra/libexec/zmdailyreport so that you use another mail library “Net::SMTP” instead of “Mail::Mailer”. With that library, emails correctly appear to come from zimbra@domain.com.
The change should be so that:
sub sendEmailReport { my %arg = @_; my $data = $arg{data}; # @Report data for message body my $subject = "Daily mail report for $arg{day}"; my $from_address = getLocalConfig("smtp_source"); my $to_address = getLocalConfig("smtp_destination"); my $smtphost = getLdapConfigValue("zimbraSmtpHostname") || "localhost"; warn("DEBUG: Sending daily report to $to_address via $smtphost\n") if ($Debug); eval { use Net::SMTP; my $smtp = Net::SMTP->new("$smtphost") or die $!; $smtp->mail( $from_address ); $smtp->to( $to_address ); $smtp->data(); $smtp->datasend("To: $to_address\n"); $smtp->datasend("From: $from_address\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); # done with header $smtp->datasend($data); # email body $smtp->dataend(); $smtp->quit(); # all done. message sent. # my $mailer = Mail::Mailer->new( "smtp", Server => $smtphost ); # $mailer->open( # { # From => $from_address, # To => $to_address, # Subject => $subject, # } # ); # print $mailer @$data; # $mailer->close(); }; if ($@) { logError("Failed to email report using SMTP via '$smtphost': $@\n"); } else { warn("DEBUG: Email report sent to $to_address\n") if ($Debug); } }
Now you also need to fix the “Service“ and “Disk” notifications of Zimbra, therefore you need to change:
/opt/zimbra/conf/swatchrc.in
From:
perlcode 0 sub dosmtp { my %args = (@_); print "SMTP notification: $args{MESSAGE}\n"; open (FOO, "|/opt/zimbra/postfix/sbin/sendmail -Am -t"); print FOO "To: $pwc\nFrom: $fr\nSubject: Service $args{SERVICE} $args{STATUS} on $args{HOST}\n\n$args{MESSAGE}\n"; close FOO; } perlcode 0 sub dodisksmtp { my %args = (@_); print "SMTP notification: $args{MESSAGE}\n"; open (FOO, "|/opt/zimbra/postfix/sbin/sendmail -Am -t"); print FOO "To: $pwc\nFrom: $fr\nSubject: Disk $args{DISK} at $args{UTIL}\% on $args{HOST}\n\n$args{MESSAGE}\n"; close FOO; }
To:
perlcode 0 sub dosmtp { my %args = (@_); print "SMTP notification: $args{MESSAGE}\n"; open (FOO, "|/opt/zimbra/postfix/sbin/sendmail -Am -t -f $fr"); print FOO "To: $pwc\nFrom: $fr\nSubject: Service $args{SERVICE} $args{STATUS} on $args{HOST}\n\n$args{MESSAGE}\n"; close FOO; } perlcode 0 sub dodisksmtp { my %args = (@_); print "SMTP notification: $args{MESSAGE}\n"; open (FOO, "|/opt/zimbra/postfix/sbin/sendmail -Am -t -f $fr"); print FOO "To: $pwc\nFrom: $fr\nSubject: Disk $args{DISK} at $args{UTIL}\% on $args{HOST}\n\n$args{MESSAGE}\n"; close FOO; }
That is, you need to just add “-f $fr” at the end of the sendmail command. When done, you need to:
su - zimbra /opt/zimbra/libexec/zmsnmpinit zmswatchctl restart