<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.staging.zoneminder.com/index.php?action=history&amp;feed=atom&amp;title=User_talk%3AJbmia</id>
	<title>User talk:Jbmia - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.staging.zoneminder.com/index.php?action=history&amp;feed=atom&amp;title=User_talk%3AJbmia"/>
	<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/index.php?title=User_talk:Jbmia&amp;action=history"/>
	<updated>2026-04-20T00:14:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.staging.zoneminder.com/index.php?title=User_talk:Jbmia&amp;diff=4609&amp;oldid=prev</id>
		<title>Jbmia: How to install and configure Postfix (as a Gmail smtp relay) + ZoneMinder for successful email delivery of alerts for Dummies...  ;-)</title>
		<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/index.php?title=User_talk:Jbmia&amp;diff=4609&amp;oldid=prev"/>
		<updated>2011-08-06T15:22:31Z</updated>

		<summary type="html">&lt;p&gt;How to install and configure Postfix (as a Gmail smtp relay) + ZoneMinder for successful email delivery of alerts for Dummies...  ;-)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== How to install and configure Postfix (as a Gmail smtp relay) + ZoneMinder for successful email delivery of alerts for Dummies...  ;-) ==&lt;br /&gt;
&lt;br /&gt;
This is a pretty rough guide at this point, but felt compelled to put something down after spending many hours searching for a solution to obtain emails from ZM events.  In the end the solution is relatively simple:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Prerequisites:  Basically command line knowledge, ability to use text editors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.  Install, configure, and test Postfix.  &lt;br /&gt;
&lt;br /&gt;
Postfix is a full featured mail server.  That said, the scope of this guide is merely to configure it for use as an &amp;quot;smtp&amp;quot; relay for Gmail. In other words, we&amp;#039;ll be using our gmail account credentials and their system to relay our event alert mail.  I found the following guide on the internet and used it to configure and test Postfix successfully:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A. Install&lt;br /&gt;
  &lt;br /&gt;
(Note the following install commands are based on yum/Fedora.  Alter based on your distribution&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Postfix and cyrus-sasl with your application manager of choice. If you&amp;#039;re compiling from source, be sure to make Postfix with the -DUSE_SASL_AUTH flag for SASL support and -DUSE_TLS for TLS support.&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;yum install postfix cyrus-sasl&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Stop the sendmail service&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;/etc/init.d/sendmail stop&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remove sendmail from the startup runlevels&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;chkconfig --del sendmail&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
B. Configure Postfix as Gmail SMTP relay&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;re attempting to relay mail using Gmail, then it will be necessary to use TLS with Postfix. You&amp;#039;ll have to point Postfix at your server&amp;#039;s trusted CA root certificate bundle, but luckily &amp;quot;...client-side certificates are not required when relaying mail to GMail&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. First, double-check that Postfix was configured with SSL support (ie. ldd should return at least one line starting with libssl):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;whereis -b postfix&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
postfix: /usr/sbin/postfix /etc/postfix /usr/libexec/postfix&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;ldd /usr/sbin/postfix&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
libssl.so.6 =&amp;gt; /lib/libssl.so.6 (0x00111000)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Now we need to find your server&amp;#039;s CA root certificate bundle, which is typically distributed with openssl. The bundle file is used by Postfix to verify Gmail&amp;#039;s SSL certificate (signed by Thawte). On my CentOS server, this file was located at /etc/pki/tls/certs/ca-bundle.crt, but may be in a different location on your box (ie. /etc/ssl/certs).  Mine was in /usr/share/doc/mutt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;locate ca-bundle.crt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
/etc/pki/tls/certs/ca-bundle.crt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit /etc/postfix/main.cf with the following values (edit-Postfix comes with a predefined template, I moved that to main.cf.bak and used Nano to create a blank file for the following content.  It was cleaner when it came to testing as the template comes with a bunch of text explanation for each setting.  If you&amp;#039;re blindly following a guide like this one, it just all gets in the way):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Copy/paste the following into a blank &amp;quot;/etc/postfix/main.cf&amp;quot; file using your favorite text editor (I like Nano):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;relayhost = smtp.gmail.com:587&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;mydomain = local.domain&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;myhostname = host.local.domain&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;myorigin = $myhostname&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtpd_sasl_path = smtpd&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_type = cyrus&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_auth_enable = yes&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_security_options = noanonymous&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_tls_security_options = noanonymous&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_use_tls  = yes&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_tls_CAfile = /path/to/your/ca-bundle.crt&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_tls_security_options = noanonymous&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Copy/paste the following into a blank &amp;quot;/etc/postfix/sasl_passwd&amp;quot; file.  Change username &amp;amp; password to your gmail username and password of course.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;# The server info must exactly match the value&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;# for &amp;quot;relayhost&amp;quot; in /etc/postfix/main.cf&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp.gmail.com:587 username:password&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Generate a postfix lookup table from the previous file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;postmap hash:/etc/postfix/sasl_passwd&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5a.  Make sure that the hash &amp;quot;took&amp;quot; by checking it with the following command, the response should be the user:pass that you defined for the file.  Basically, we&amp;#039;re confirming that Postfix has the ability to pull up the user:pass when it needs it and you didn&amp;#039;t hose the command with the wrong path or file name or something:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;postmap -q&amp;#039;: postmap -q smtpout.secureserver.net /etc/postfix/sasl_passwd&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Get rid of the clear text password file  (I&amp;#039;d really do this at the end, once it&amp;#039;s confirmed functional, but don&amp;#039;t forget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;rm /etc/postfix/sasl_passwd&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C1. Restart postfix and send a test email&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;postfix reload&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;sendmail email@example.com&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Test relay thru Gmail&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Go check your the email account you sent your test email to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Troubleshooting&lt;br /&gt;
&lt;br /&gt;
Monitor postfix mail log in a separate session with the following command&lt;br /&gt;
&lt;br /&gt;
$ &amp;#039;&amp;#039;&amp;#039;tail -f /var/log/maillog&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If the log is displaying the following error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Authentication failed: cannot SASL authenticate to server ...: no mechanism available)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then set this variable in /etc/postfix/main.cf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;smtp_sasl_security_options = noanonymous&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the log is displaying this error: &amp;quot;553 Sorry, that domain isn&amp;#039;t in my list of allowed rcpthosts. (in reply to RCPT TO command)&amp;quot;, &lt;br /&gt;
Check your username and password in /etc/postfix/sasl_passwd. Your user name is usually your full email address. If you have to fix it, don&amp;#039;t forget to use postmap to generate a new lookup table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Configure ZoneMinder.   There&amp;#039;s not really alot to this.  Many of the forum posts I checked had me altering zmfilter.pl with User &amp;amp; Pass Auth values and suggesting ssmtp instead of smtp and so on... I didn&amp;#039;t have success with those methods.  With Postfix installed and confirmed running, zmfilter.pl doesn&amp;#039;t need to be modified in any way, so if you&amp;#039;ve already altered it, back those changes out or restore the backup you should have made.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I won&amp;#039;t get into alot of detail on each field of the &amp;quot;email&amp;quot; tab in &amp;quot;options&amp;quot;, but thats where you need to be.. you need to put in your to email and your from email address and your smtp server.  That&amp;#039;s the only thing specific to this guide, the smptp, server, don&amp;#039;t put gmails there, since we&amp;#039;ve configured Postfix with all that.  Just put in &amp;quot;localhost&amp;quot;.  That&amp;#039;s really it.  That&amp;#039;s all there is that&amp;#039;s specific on the ZM side to getting ZM working with Postfix.  Pretty simple huh..  You can play around with email content settings later.  That&amp;#039;s out of scope for this guide, we&amp;#039;re just trying to get something/anything on the other end of the pipe...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C.  Generate an alert event if you don&amp;#039;t have one already and create a filter that sends an email.  Refer to the docs for that step.. it&amp;#039;s basic stuff.. all you have to do is create a filter that will pick up at least one event and then tick the email box and click execute.  If you click save and then tick the &amp;quot;run filter in background&amp;quot; option it&amp;#039;ll sit there and wait for an event to occur (according to your filter properties) and automatically shoot an email out to you. Cool.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
This is a rough guide (no pretty formatting or anything), but it got the job done quickly and easily for me after I&amp;#039;d spent maybe 48 hours combined pursuing other blind allies..  Good luck.  Huge thanks to a guy named Tim White at Zulius for putting together the Postfix portion of this guide. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;/div&gt;</summary>
		<author><name>Jbmia</name></author>
	</entry>
</feed>