{"id":44,"date":"2003-05-31T08:30:28","date_gmt":"2003-05-31T08:30:28","guid":{"rendered":"http:\/\/fiveforks.com\/jeb\/2003\/05\/sendmail\/"},"modified":"2003-05-31T08:30:28","modified_gmt":"2003-05-31T08:30:28","slug":"sendmail","status":"publish","type":"post","link":"https:\/\/www.fiveforks.com\/jeb\/2003\/05\/sendmail\/","title":{"rendered":"SendMail"},"content":{"rendered":"<p>[Update: 6\/20\/2005. With 10.3.9 sendmail is configured to run &#8220;Automatic&#8221;. It just works w\/ no configuration or fixes required. So notifications worked right away when I moved to the G3 running OS X 10.3.9.]<\/p>\n<p>Sendmail quit working properly at some point. This meant notifications generated by MovableType were not being delivered. They were stuck somewhere.<\/p>\n<p>This may have been caused by an Apple update of some kind. I think creating the NetInfo entry as described in <a>on these pages<\/a> is what finally solved the problem.<\/p>\n<p><!--more--><br \/>\n<b>Getting NetInfo out of the Picture<\/b><\/p>\n<p>Some of the Apple documentation on sendmail (notably, the \/etc\/mail\/README file) implies that it&#8217;s a good idea to set a few properties in NetInfo to ensure that the sendmail binary reads its configuration from \/etc\/mail\/sendmail.cf. So far, I&#8217;ve not had a problem with this, but in the interest of making sure that we don&#8217;t get bit by a modified sendmail binary from Apple in the future, we should go ahead and execute the commands that will modify the netinfo database:<\/p>\n<p><font color=\"purple\">% sudo niutil -create . \/locations\/sendmail<\/font><\/p>\n<p><font color=\"purple\">% sudo niutil -createprop . \/locations\/sendmail sendmail.cf \/etc\/mail\/sendmail.cf<\/font><\/p>\n<p><font color=\"red\"><\/p>\n<h2>TIPS TO SELF:<\/h2>\n<p>Use Pseudo and BBEdit to edit\/create files.<\/p>\n<p>Login as root in all terminal commands.<\/p>\n<p>Running the update script will not echo any feedback if the source file and target file are &#8220;equal&#8221;. (So change something just to make sure.)<\/font><\/p>\n<h2><i>Here are the two full pages I used&#8230;<\/i><\/h2>\n<h3>Working with Configuration Files<\/h3>\n<p>As soon as you decide to work with sendmail&#8217;s configuration<\/p>\n<p>files, you&#8217;ll find out that there is a lot of confusing stuff in there.<\/p>\n<p>Take a look at the <code>\/etc\/mail\/sendmail.cf<\/code> file. The first thing you see is a header that says:<\/p>\n<pre><code>##### &nbsp;&nbsp; DO NOT EDIT THIS FILE! Only edit the source .mc file.<\/code><\/pre>\n<p>Scroll down a bit further and you&#8217;ll see some stuff that<\/p>\n<p>could only be friendly looking to an old-time Perl hacker:<\/p>\n<pre><code># hostnames ending in class P are always canonical\n\nR$* &lt; @ $* $=P &gt; $*             $: $1 &lt; @ $2 $3 . &gt; $4\n\nR$* &lt; @ $* $~P &gt; $*             $: $$| $1 &lt; @ $2 $3 &gt; $4\n\nR$* CC $* $| $* &lt; @ $+.$+ &lt; $*  $: $3 &lt; @ $4.$5 . &gt; $6\n\nR$* CC $* $| $*                 $: $3\n\n# pass to name server to make hostname canonical\n\nR$* $| $* &lt; @ $* &gt; $*           $: $2 &lt; @ $[ $3 $] &gt; $4\n\nR$* $| $*                       $: $2<\/code><\/pre>\n<p>So, if you&#8217;re not supposed to edit this file, and really<\/p>\n<p>wouldn&#8217;t want to even if you should, what are you supposed to do? The answer is<\/p>\n<p>to ignore it. Treat it like a binary file. You don&#8217;t muck about in the <code>\/bin\/sh<\/code> executable to use it do you? Take the same approach to <code>\/etc\/mail\/sendmail.cf<\/code>.<\/p>\n<p>Instead, we&#8217;re going to see how to edit the source code for<\/p>\n<p>this file. Take a look at the <code>\/usr\/share\/sendmail\/conf\/cf\/generic-darwin.mc<\/code> file. The body of it looks like this:<\/code><\/p>\n<pre><code>VERSIONID(`$Id: generic-darwin.mc,v 1.3 2002\/04\/12 18:41:47 bbraun Exp $')\n\nOSTYPE(darwin)dnl\n\nDOMAIN(generic)dnl\n\nundefine(`ALIAS_FILE')\n\ndefine(`PROCMAIL_MAILER_PATH',`\/usr\/bin\/procmail')\n\nFEATURE(`smrsh',`\/usr\/libexec\/smrsh')\n\nFEATURE(local_procmail)\n\nFEATURE(`virtusertable',`hash -o \/etc\/mail\/virtusertable')dnl\n\nFEATURE(`genericstable', `hash -o \/etc\/mail\/genericstable')dnl\n\nFEATURE(`mailertable',`hash -o \/etc\/mail\/mailertable')dnl\n\nFEATURE(`access_db')dnl\n\nMAILER(smtp)\n\nMAILER(procmail)<\/code><\/pre>\n<p>This is <b>much<\/b> more approachable than <code>sendmail.cf<\/code> ever could be. This is actually a script written in the m4 macro language. m4 has been around for a while and Mac OS X ships with GNU m4 version 1.4. Luckily, it is simple enough to use without having to learn much about it. If you are interested in learning more, see the <a href=\"http:\/\/www.gnu.org\/software\/m4\/m4.html\">GNU m4<\/a> project page.<\/p>\n<p>So, this is the source code we&#8217;ll use to configure sendmail.<\/p>\n<p>Let&#8217;s make a copy of it and put it into a place where we will remember where it<\/p>\n<p>is:<\/p>\n<pre><code>% <strong>sudo cp \/usr\/share\/sendmail\/conf\/cf\/generic-darwin.mc \/etc\/mail\/config.mc<\/strong><\/code><\/pre>\n<p>We now have a copy of the source code for the <code>sendmail.cf<\/code> file in a place where we can edit it and keep track of where it is. However, even if you have a copy of the source code, you still have to know how to compile the file. In our case, the set of commands to compile the <code>config.mc<\/code> file to <code>sendmail.cf<\/code> looks something like:<\/p>\n<pre><code>m4 \/usr\/share\/sendmail\/conf\/m4\/cf.m4 \/etc\/mail\/config.mc &gt; \/tmp\/sendmail.cf<br \/>\n\nmv \/etc\/mail\/sendmail.cf \/etc\/mail\/sendmail.cf.old<br \/>\n\nmv \/tmp\/sendmail.cf \/etc\/mail\/sendmail.cf<\/code><\/pre>\n<p>Yikes! That&#8217;s too much to remember. It goes against my philosophy of keeping things as simple as possible (without being too simple that is!). Luckily, I&#8217;ve written a little script that should help this part of working with sendmail&#8217;s configuration files, as well as some of<\/p>\n<p>the others.<\/p>\n<h3>A Script to Simplify Your Life<\/h3>\n<p>The following script will compile <code>config.mc<\/code> into <code>sendmail.cf<\/code> and restart sendmail so that it will notice the configuration changes. You can put it anywhere you want, I happen to have placed my copy in the <code>\/etc\/mail<\/code> folder so that I can find it easily. Fire up your editor of choice and cut-and-paste this in. Then, if you want to mirror what I&#8217;ve done, save it to <code>\/etc\/mail\/update<\/code>. Otherwise, you might want to save it as <code>\/usr\/local\/bin\/sendmail-update<\/code> or some other fairly easy to remember location.<\/p>\n<pre><code>#! \/bin\/sh\n\nif [ \/etc\/mail\/config.mc -nt \/etc\/mail\/sendmail.cf ]\n\nthen\n\necho Regenerating sendmail.cf\n\nm4 \/usr\/share\/sendmail\/conf\/m4\/cf.m4 \/etc\/mail\/config.mc &gt; \\\n\n\/tmp\/sendmail.cf\n\nmv \/etc\/mail\/sendmail.cf \/etc\/mail\/sendmail.cf.old\n\nmv \/tmp\/sendmail.cf \/etc\/mail\/sendmail.cf\n\n\/System\/Library\/StartupItems\/Sendmail\/Sendmail restart\n\nfi<\/code><\/pre>\n<p>We&#8217;re going to add a bit more to this script later. But for<\/p>\n<p>now, we&#8217;re ready to feed sendmail a little anti-paranoia medicine. <\/p>\n<h3>Back to Don&#8217;t Blame sendmail<\/h3>\n<p>In order to use the <code>DontBlameSendmail<\/code> configuration parameter with sendmail, all we need to do is add one line to the <code>config.mc<\/code> file.<\/p>\n<p>Edit it to match the following. The line you need to add is bold-faced.<\/p>\n<pre><code>% sudo emacs \/etc\/mail\/config.mc\n\nVERSIONID(`$Id: generic-darwin.mc,v 1.3 2002\/04\/12 18:41:47 bbraun Exp $')\n\nOSTYPE(darwin)dnl\n\nDOMAIN(generic)dnl\n\nundefine(`ALIAS_FILE')\n\ndefine(`PROCMAIL_MAILER_PATH',`\/usr\/bin\/procmail')\n\n<strong>define(`confDONT_BLAME_SENDMAIL', `GroupWritableDirPathSafe')<\/strong>\n\nFEATURE(`smrsh',`\/usr\/libexec\/smrsh')\n\nFEATURE(local_procmail)\n\nFEATURE(`virtusertable',`hash -o \/etc\/mail\/virtusertable')dnl\n\nFEATURE(`genericstable', `hash -o \/etc\/mail\/genericstable')dnl\n\nFEATURE(`mailertable',`hash -o \/etc\/mail\/mailertable')dnl\n\nFEATURE(`access_db')dnl\n\nMAILER(smtp)\n\nMAILER(procmail)<\/code><\/pre>\n<p>Be careful to note that the quoting around the values use both the <code>`<\/code> and <code>'<\/code> characters around the arguments to the <code>define<\/code> statement.. Save the file. Next we need to compile it. Execute your update script. You may need to remember to give it execute permissions (<code>`chmod g+x \/etc\/mail\/update'<\/code>) first!<\/p>\n<pre><code>% <strong>sudo .\/update<\/strong>\n\nRegenerating sendmail.cf\n\nRestarting mail services<\/code><\/pre>\n<p>That&#8217;s all you need to do. If you followed my previous advice in <a href=\"\/pub\/a\/mac\/2002\/08\/23\/jaguar_server.html\">Setting Up a Site Server with Jaguar<\/a> and sendmail is already running, then you can remove the <code>`chmod g-w \/ \/Users'<\/code> line in the <code>\/System\/Library\/StartupItems\/Sendmail\/Sendmail<\/code> script. Be sure to edit the root crontab entry as well.<\/p>\n<p>If you didn&#8217;t and don&#8217;t have sendmail running, just execute the system startup script with the <code>start<\/code> argument:<\/p>\n<p><code>% <b>sudo \/System\/Library\/StartupItems\/Sendmail\/Sendmail start<\/b><\/code><\/p>\n<p>Also, If you haven&#8217;t already done so, be sure to edit <code>\/etc\/hostconfig<\/code>to have sendmail startup when the system starts. If you can&#8217;t remember how to do this, refer back to the <a href=\"\/pub\/a\/mac\/2002\/08\/23\/jaguar_server.html\">Setting Up a Site Server<\/a>).<\/p>\n<h3>Getting NetInfo out of the Picture<\/h3>\n<p>Some of the Apple documentation on sendmail (notably, the <code>\/etc\/mail\/README<\/code> file) implies that it&#8217;s a good idea to set a few properties in NetInfo to ensure that the sendmail binary reads its configuration from <code>\/etc\/mail\/sendmail.cf<\/code>. So far, I&#8217;ve not had a problem with this, but in the interest of making sure that we don&#8217;t get bit by a modified sendmail binary from Apple in the future, we should go ahead and execute the commands that will modify the netinfo database:<\/code><\/p>\n<p><code>% <b>sudo niutil -create . \/locations\/sendmail<\/b><\/p>\n<p>% <b>sudo niutil -createprop . \/locations\/sendmail sendmail.cf \/etc\/mail\/sendmail.cf<\/b><\/code><\/p>\n<p>Now, we are going to take a look at several other features<\/p>\n<p>that you can tweak and the various results they have.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Update: 6\/20\/2005. With 10.3.9 sendmail is configured to run &#8220;Automatic&#8221;. It just works w\/ no configuration or fixes required. So notifications worked right away when I moved to the G3 running OS X 10.3.9.] Sendmail quit working properly at some &hellip; <a href=\"https:\/\/www.fiveforks.com\/jeb\/2003\/05\/sendmail\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":0,"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fiveforks.com\/jeb\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}