<p>I've always found checkin (commit) mails to be very useful for keeping track of what work other people are doing in the codebase / repository. How do I set up SVN to email a distribution list on each commit?</p>

<p>I'm running clients on Windows and the Apache Subversion server on Linux. The answers below for various platforms will likely be useful to other people though.</p>

[{'answer_id': 7922, 'author': 'Rytmis', 'author_id': 266, 'author_profile': 'https://Stackoverflow.com/users/266', 'pm_score': 2, 'selected': False, 'text': '<p>You\'ll want to familiarize yourself with <a href="http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.reposhooks" rel="nofollow noreferrer" title="The Subversion Book: Repository hooks">repository hooks</a>, particularly the <a href="http://www.petefreitag.com/item/244.cfm" rel="nofollow noreferrer" title="Using Subversion hooks to send out build emails">post-commit hook</a>.</p>\n'}, {'answer_id': 7924, 'author': 'pix0r', 'author_id': 72, 'author_profile': 'https://Stackoverflow.com/users/72', 'pm_score': 6, 'selected': True, 'text': '<p>You use the <a href="http://svnbook.red-bean.com/en/1.7/svn.reposadmin.create.html#svn.reposadmin.create.hooks" rel="noreferrer">post-commit hooks</a>.  Here\'s a <a href="http://builddeploy.blogspot.com/2008/01/implementing-subversion-post-commit.html" rel="noreferrer">guide</a>.</p>\n\n<p>Here\'s a sample Ruby script that sends an email after each commit: <a href="http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/commit-email.rb" rel="noreferrer">commit-email.rb</a></p>\n'}, {'answer_id': 7928, 'author': 'epatel', 'author_id': 842, 'author_profile': 'https://Stackoverflow.com/users/842', 'pm_score': 1, 'selected': False, 'text': '<p>What platform?</p>\n\n<p>On Mac OS X I have installed <a href="http://msmtp.sourceforge.net/" rel="nofollow noreferrer">msmtp</a> and created a post-commit script under hooks in the repository. A .msmtprc file needs to be setup for the <code>svn</code> (or <code>www</code>) user.</p>\n\n<pre><code>REPOS="`echo $1 | sed \'s/\\/{root of repository}//g\'` "\nREV="$2"\nMSG=`/usr/local/bin/svn log -v -r HEAD https://localhost$REPOS`\n\n/usr/local/bin/msmtp {list of recipients} &lt;&lt;EOF\nSubject: SVN-Commit $REPOS#$REV\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8Bit\n\n$MSG\nEOF\n</code></pre>\n\n<p>Make <code>{root of repository}</code> and <code>{list of recipients}</code> specific for your needs. Note I have used UTF-8 because we have some special characters here in Sweden (åäö).</p>\n'}, {'answer_id': 7931, 'author': 'Sean Carpenter', 'author_id': 729, 'author_profile': 'https://Stackoverflow.com/users/729', 'pm_score': 0, 'selected': False, 'text': '<p>There is a (large) example written in Perl included in the Subversion source (it can be <a href="http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/commit-email.pl.in" rel="nofollow noreferrer">viewed here</a>).</p>\n'}, {'answer_id': 7943, 'author': 'Marius', 'author_id': 1008, 'author_profile': 'https://Stackoverflow.com/users/1008', 'pm_score': 4, 'selected': False, 'text': '<p>Have a look at the standalone <a href="http://sourceforge.net/projects/svn-notify/" rel="noreferrer">Subversion Notify</a> tool <strong>(Windows only!)</strong>\nIt can do emailing on commit and also much more!</p>\n'}, {'answer_id': 7986, 'author': 'Matt Miller', 'author_id': 763, 'author_profile': 'https://Stackoverflow.com/users/763', 'pm_score': 1, 'selected': False, 'text': '<p>There\'s a related question <a href="https://stackoverflow.com/questions/6155/common-types-of-subversion-hooks#6359">here</a> on post-commit hooks. Personally, I prefer to send a message to something I can get an RSS feed from, as an email-per-commit would overload my inbox pretty quickly.</p>\n'}, {'answer_id': 8286, 'author': 'Jason Sparks', 'author_id': 512, 'author_profile': 'https://Stackoverflow.com/users/512', 'pm_score': 1, 'selected': False, 'text': '<p>Seconding @<a href="https://stackoverflow.com/questions/7913/how-do-i-make-subversion-svn-send-email-on-checkins#7986">Matt Miller</a> on RSS feeds. </p>\n\n<p>There\'s a useful tool called <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a> that offers RSS feeds of every repository and individual branches/tags/folders with full commit messages. It\'s also a great web interface for quickly looking at file histories and commits/diffs without having to run an update and open your editor of choice.</p>\n'}, {'answer_id': 8295, 'author': 'Will Dean', 'author_id': 987, 'author_profile': 'https://Stackoverflow.com/users/987', 'pm_score': 1, 'selected': False, 'text': '<p>As someone else said, \'what platform\'.   On Windows I\'ve used \'blat\', which is a freebie command line SMTP mailer to do this, along with a post-commit and another batch file.</p>\n\n<p>The post commit looks like this:  (Just calls another batch file)</p>\n\n<pre><code> call d:\\subversion\\repos\\rts\\hooks\\mail %1 %2\n</code></pre>\n\n<p>And mail.bat looked like this:</p>\n\n<pre><code>copy d:\\subversion\\repos\\RTS\\hooks\\Commitmsg.txt %temp%\\commit.txt\ncopy d:\\subversion\\repos\\RTS\\hooks\\subjbase.txt %temp%\\subject.txt\nsvnlook info -r %2 %1 &gt;&gt; %temp%\\commit.txt\necho Revision %2 &gt;&gt; %temp%\\commit.txt\nsvnlook changed -r %2 %1 &gt;&gt; %temp%\\commit.txt\nsvnlook author -r %2 %1 &gt;&gt; %temp%\\subject.txt\nc:\\utils\\blat %temp%\\commit.txt -t &lt;me@my.email.com&gt; -sf %temp%\\subject.txt -server ServerName -f "SVN Admin &lt;svn@my.email.com&gt;" -noh2\n</code></pre>\n\n<p>The biggest gotcha in writing SVN hooks is that you might have basically NO environment set-up - no exe path, no temp path, etc.  Though maybe that\'s improved in more recent SVN builds.</p>\n'}, {'answer_id': 26847, 'author': 'Mark Spangler', 'author_id': 456684, 'author_profile': 'https://Stackoverflow.com/users/456684', 'pm_score': 1, 'selected': False, 'text': '<p>I use a post-commit script similar to this <a href="http://gurge.com/blog/2006/09/10/subversion-post-commit-email-hook-in-ruby/" rel="nofollow noreferrer">one</a>.</p>\n\n<p>It\'s sends a nice HTML email. I updated it some where it highlights code that was removed in red and highlights code that was added in blue.</p>\n'}, {'answer_id': 80149, 'author': 'whitney', 'author_id': 14948, 'author_profile': 'https://Stackoverflow.com/users/14948', 'pm_score': 1, 'selected': False, 'text': '<p>You could use <a href="http://buildbot.net" rel="nofollow noreferrer">buildbot</a>.  It\'s a tool that can take arbitrary action whenever a check-in occurs.  It\'s a full featured continuous integration system but if you just want emails it can certainly handle that.  It has plug-ins for a variety of SCMs including SVN.</p>\n'}, {'answer_id': 3506646, 'author': 'Logan', 'author_id': 1127433, 'author_profile': 'https://Stackoverflow.com/users/1127433', 'pm_score': 1, 'selected': False, 'text': '<p>In the "hooks" directory of your specific subversion branch there are 9 template files to get you started. </p>\n\n<p>Key point: subversion will not execute any of the files until they are renamed. To get post-commit.tmpl to execute under unix, rename it "post-commit". Under Windows, rename it to "post-commit.bat" or "post-commit.exe". Subversion will <strong>not</strong> execute the file if it is named "post-commit.tmpl" or "post-commit.sh" or the like. </p>\n\n<p>Also, make sure that the file is executable by the same user that runs subversion. </p>\n'}, {'answer_id': 14544102, 'author': 'kervin', 'author_id': 16549, 'author_profile': 'https://Stackoverflow.com/users/16549', 'pm_score': 0, 'selected': False, 'text': '<p>Also <a href="http://opensource.perlig.de/svnmailer/" rel="nofollow">SVNMailer</a>, which works on Linux.</p>\n'}, {'answer_id': 17183899, 'author': 'Guardian', 'author_id': 1778820, 'author_profile': 'https://Stackoverflow.com/users/1778820', 'pm_score': 0, 'selected': False, 'text': '<p>Check the <strong>svn-mod-email</strong> package described <a href="http://tkurek.blogspot.com/2013/05/svn-email-notifications-svn-mod-email_21.html" rel="nofollow">here</a>. The <strong>svn-mod-email</strong> is a powerful tool for SVN email notifications management that is delivered as a Debian archive. It\'s easily to install, configure and use.</p>\n'}, {'answer_id': 19270610, 'author': 'bahrep', 'author_id': 761095, 'author_profile': 'https://Stackoverflow.com/users/761095', 'pm_score': 2, 'selected': False, 'text': '<p>VisualSVN Server has useful commit e-mail notification hook <code>VisualSVNServerHooks.exe</code>. It supports colored diffs and can send commit notifications only when commit affects certain repository path. </p>\n\n<p>See <a href="http://www.visualsvn.com/support/topic/00018/" rel="nofollow">"Configuring Email Notifications in VisualSVN Server"</a>.</p>\n'}, {'answer_id': 20576816, 'author': 'Sagar Zaveri', 'author_id': 1383016, 'author_profile': 'https://Stackoverflow.com/users/1383016', 'pm_score': 2, 'selected': False, 'text': '<p>1) Install svnnotify on a svn server using sudo apt-get</p>\n\n<p>2) Use post-commit hook of your repo (read on post-commit hooks on svn website)</p>\n\n<p>3) Open post-commit hook file and paste following code to send an email using smtp server.\n    Using smtp is straight forward since you don\'t need to configure sendmail.</p>\n\n<p>4) Make sure after \\ (line break) you don\'t have an extra space.</p>\n\n<pre><code>#!/bin/sh\n\nREPOS="$1"\nREV="$2"\nTO="xyz@yah.com" # who will receive the notifications\nFROM="hello@goog.com" # what will be in "FROM" fields\n\n\n /usr/bin/svnnotify \\\n\n--repos-path "$REPOS" \\\n--revision "$REV" \\\n--to $TO \\\n--from $FROM \\\n--reply-to $FROM \\\n--smtp "YOUR.SMTP.MAIL.COM" \\\n--subject-prefix "[svn commit]" \\\n--attach-diff -a \\\n--header \'Message generated on Subversion Check-in.\' \\\n--footer \'OpenSource Team. \' \\\n--svnlook "/usr/local/bin/svnlook" \\\n--handler HTML::ColorDiff # make diff pretty\n</code></pre>\n'}, {'answer_id': 23951956, 'author': 'Danijel', 'author_id': 1202172, 'author_profile': 'https://Stackoverflow.com/users/1202172', 'pm_score': 1, 'selected': False, 'text': '<p>I did it on Linux server in 3 steps: </p>\n\n<ol>\n<li><p>Create a mailing list (<code>svn-notify@xy.com</code>) and add people to the list.</p></li>\n<li><p>Edit <code>/path_to_your_svn/svn/hooks/svn-notify/mailer.conf</code></p>\n\n<ul>\n<li>to_addr = svn-notify@xy.com</li>\n<li>from_addr = %(author)s@xy.com</li>\n<li>commit_subject_prefix =[XY-SVN] </li>\n</ul></li>\n<li>Add this line to your <code>/path_to_your_svn/svn/hooks/post-commit</code> file:<br>\n<code>/path_to_your_svn/svn/hooks/svn-notify/mailer.py commit "$REPOS" "$REV" /path_to_your_svn/svn/hooks/svn-notify/mailer.conf</code></li>\n</ol>\n'}]
['https://Stackoverflow.com/questions/7913', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1031/']