{"id":1041,"date":"2023-09-15T09:16:07","date_gmt":"2023-09-14T21:16:07","guid":{"rendered":"https:\/\/fishy.fisher.net.nz\/?page_id=1041"},"modified":"2023-09-15T10:37:20","modified_gmt":"2023-09-14T22:37:20","slug":"how-i-set-up-email-alerts-on-zoneminder-on-debian-12","status":"publish","type":"page","link":"https:\/\/fishy.fisher.net.nz\/?page_id=1041","title":{"rendered":"How I set up Email Alerts on Zoneminder on Debian 12"},"content":{"rendered":"<p><strong>First you will have to install MSMTP<\/strong>\u00a0 ( If<br \/>\nssmtp , sendmail\u00a0 available , please uninstall completely )<\/p>\n<p>Open the terminal and run<\/p>\n<p><code>sudo apt install msmtp<\/code><\/p>\n<p>Then create sendmail file which a symlink of msmtp ( at \/usr\/bin)\u00a0 in<br \/>\n\/usr\/sbin\/<\/p>\n<p>Note: before making below symlink , make sure that there is no sendmail<br \/>\nfile in \/usr\/bin<\/p>\n<p><code>sudo ln -s \/usr\/bin\/msmtp \/usr\/sbin\/sendmail<\/code><\/p>\n<p>When zmfilter.pl searchs\u00a0 for \/usr\/sbin\/sendmail , it redirects to<br \/>\nmsmtp which is the main executable file at \/usr\/bin\/<\/p>\n<p><strong>Now you will have to create a configuration file called msmtprc<\/strong><br \/>\nwhich contains email hosts ,ports ,certificates ,email details etc at the<br \/>\ndirectory \/etc\/<br \/>\n<code>sudo nano \/etc\/msmtprc<\/code><br \/>\nWhen the empty file is opened, enter the following scripts<br \/>\n<code># Set default values for all following accounts.<br \/>\ndefaults<br \/>\nauth\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 on<br \/>\ntls\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 on<br \/>\ntls_trust_file \/etc\/ssl\/certs\/ca-certificates.crt<br \/>\nlogfile\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ~\/.msmtp.log<br \/>\n# Gmail<br \/>\naccount\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 gmail<br \/>\nhost\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 smtp.gmail.com<br \/>\nport\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 587<br \/>\nfrom\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 your gmail address<br \/>\nuser\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 your gmail address<br \/>\npassword\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 your gmail \"app\" password<br \/>\n# Set a default account<br \/>\naccount default : gmail<\/code><\/p>\n<p>Exit and save the file<\/p>\n<p>Note: for info on Gmail App passwords see <a href=\"https:\/\/support.google.com\/mail\/answer\/185833?hl=en\">https:\/\/support.google.com\/mail\/answer\/185833?hl=en<\/a><\/p>\n<p>To add group www-data to the file<\/p>\n<p><code>sudo chown root:www-data \/etc\/msmtprc<\/code><\/p>\n<p>Now you can try a test mail on the terminal<\/p>\n<p><code>echo \"Subject: msmtp test\" | msmtp -v an.em@il.address<\/code><\/p>\n<p>(replace an.em@il.address with a real address)<\/p>\n<p><strong>Now go to Options\/Email on the ZM-Console<\/strong> and set the<br \/>\nfollowing:-<\/p>\n<p>OPT_EMAIL\u00a0\u00a0 ticked<br \/>\nMESSAGE_ADDRESS\u00a0\u00a0 I do not think this needs to be entered here as<br \/>\nit is now entered in the &#8220;Filter&#8221;<br \/>\nNEW_MAIL_MODULES\u00a0\u00a0 ticked<br \/>\nEMAIL_HOST\u00a0\u00a0 localhost<br \/>\nFROM_EMAIL\u00a0\u00a0 the same address you used in the \/etc\/msmtprc connfig<br \/>\nfile<br \/>\nURL\u00a0\u00a0 e.g. http:\/\/host.your.domain\/zm\/index.php<br \/>\nSSMTP_MAIL\u00a0\u00a0\u00a0 ticked<br \/>\nSSMTP_PATH\u00a0\u00a0\u00a0 \/usr\/bin\/msmtp<\/p>\n<p><strong>To set up filters<\/strong> you now enter the &#8220;Email Body&#8221; with<br \/>\nwhat used to be entered in the Options Email &#8220;Message_Body&#8221;I used:-<\/p>\n<p>ZM alarm detected &#8211; %EL% secs, %EF%\/%EFA% frames, t%EST%\/m%ESM%\/a%ESA% score.<\/p>\n<p>Attach (first) event image with the highest score : %EIM%<br \/>\nPath to the event stream : %EPS%<br \/>\nPath to your ZoneMinder console : %ZP%<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First you will have to install MSMTP\u00a0 ( If ssmtp , sendmail\u00a0 available , please uninstall completely ) Open the terminal and run sudo apt install msmtp Then create sendmail file which a symlink of msmtp ( at \/usr\/bin)\u00a0 in \/usr\/sbin\/ Note: before making below symlink , make sure that there is no sendmail file [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1041","page","type-page","status-publish","hentry","post-preview"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages\/1041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1041"}],"version-history":[{"count":7,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages\/1041\/revisions"}],"predecessor-version":[{"id":1053,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages\/1041\/revisions\/1053"}],"wp:attachment":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}