Configuring Email Notifications in VisualSVN Server

VisualSVN Server includes simple Subversion hook for email notifications.

To enable the email notifications on every commit please do the following:

  1. Start VisualSVN Server Manager.
  2. Open Properties for your repository.
  3. Select Hooks tab.
  4. Edit the Post-commit hook.
  5. Enter the following command into the hook editor replacing parameters with valid values.
    "%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
        commit-notification "%1" -r %2 ^
        --from <from-email> --to <to-email> ^
        --smtp-server <smtp-server>
    
Warning
Email notification ignores access rights set for accounts. It sends all commits to the specified address. You can add your own logic to the hook script if you need to limit commits that should be sent.

There are following options for the commit-notification command:

Option Meaning
-r [--revision] ARG Specifies revision number.
--from ARG Specifies the FROM e-mail address for commit notifications. To substitute commit author username in FROM, use $(author) variable.
For example: --from $(author)@example.com
--to ARG Specifies the TO e-mail address for commit notifications. To send notifications to multiple recipients, use semicolons to separate destination e-mail addresses and surround the entire list of e-mails with quotes.
For example: --to "devs@example.com;testers@example.com"
--cc ARG Specifies the CC email address for commit notifications. To substitute commit author username in CC, use the $(author) variable.

The option is available starting with VisualSVN Server 5.0.

For example: --cc "supervisors@example.com;testers@example.com"
--reply-to ARG Specifies the Reply-To email address for commit notifications. To substitute commit author username in CC, use the $(author) variable.

The option is available starting with VisualSVN Server 5.0.

For example: --reply-to commits@example.com
--filter ARG Send commit-notification email only when commit affects certain repository path. Use multiple --filter options to specify different repository paths.
For example: --filter "/MyProject/trunk" --filter "/MyProject/branches"
--smtp-server ARG Specifies the SMTP server.
--smtp-port ARG Specifies the SMTP server port. By default port 25 will be used.
--smtp-user ARG Specifies the user name that will be used to connect SMTP server.
--smtp-password <password> Specifies the password that will be used to connect SMTP server.
--smtp-ssl Enables usage of SSL when connecting SMTP server. By default the SSL protocol is disabled.
--smtp-starttls This option secures the SMTP session using the STARTTLS command. The SMTP server must support TLS encryption and the STARTTLS extension, or the connection will fail.

The option is available starting with VisualSVN Server 5.0.
--smtp-profile ARG The option makes the hook use the connection settings from the specified SMTP profile. The option accepts a name of the SMTP profile. Read the article KB183: Understanding SMTP profiles in VisualSVN Server for more information.

The option is available starting with VisualSVN Server 5.0.

For example: --smtp-profile MyProfile
--no-diffs Do not include the difference of changes in the email.
--no-html Do not use HTML email. HTML email is used by default.
--subject ARG Customizes the email subject. The option is available starting with VisualSVN Server 3.8.

The argument defines the email subject template and can include the following substitution variables:
$(repo) — repository name
$(revision) — committed revision number
$(author)svn:author property value for the committed revision

For example: --subject "[Department1] $(repo): r$(revision)"

Default value is: "$(repo): r$(revision)"
--encoding <encoding> Specifies the encoding that is used to store text files (commit notification e-mails will be sent in UTF-8). For example --encoding ISO-8859-1. Current locale settings will be used by default.

The following options are deprecated:

Option Meaning
--detailed-subject DEPRECATED. Include commit author name in email subject. Equivalent to specifying --subject "$(repo): r$(revision) by $(author)"

Example: configuring email notifications using Google Apps SMTP

To send email notifications to Gmail or Google Apps users via the Google Apps SMTP service you are required to enter the following command in the post-commit hook:

"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
    commit-notification "%1" -r %2 ^
    --from "svn.server@example.com" --to "svn.commits@example.com" ^
    --smtp-server aspmx.l.google.com
Note
Do not forget to check the Spam label if recipients don't see commit notifications in their Inbox. Also please note that the above example works only if you are sending commit notifications to Gmail or Google Apps users. Consider to configure Google SMTP relay service and then use --smtp-server smtp-relay.gmail.com option if you would like to send commit notifications elsewhere.
Last Modified: