pythongitgithookspost-receive-email

How to debug / correctly setup git-multimail


I would like to use git-multimail as post receive hook in one of my git repositories (no gitolite used). Unfortunately, I cannot get it work, and I have hardly any experience using Python.

What I did so far:

  1. I added the following block to the project.git/config file:

 

[multimailhook]
    mailingList = email@example.com
    from = email@example.com
    envelopeSender = email@example.com
    mailer = smtp
    smtpServer = smtp.mydomain.com
    smtpUser = myUser
    smtpPass = myPassword

Please note that I do not know whether "smtp", which is defined in the mailer variable, is installed on my machine.

  1. I copied the current git_multimail.py file into project.git/hooks.
  2. I created a project.git/hook/post-receive file with the following content. The file is executable, I copied this from https://github.com/git-multimail/git-multimail/blob/master/git-multimail/post-receive.example

 

#! /usr/bin/env python

import sys
import os
import git_multimail

config = git_multimail.Config('multimailhook')

try:
    environment = git_multimail.GenericEnvironment(config=config)
    #environment = git_multimail.GitoliteEnvironment(config=config)
except git_multimail.ConfigurationException:
    sys.stderr.write('*** %s\n' % sys.exc_info()[1])
sys.exit(1)

mailer = git_multimail.choose_mailer(config, environment)

git_multimail.run_as_post_receive_hook(environment, mailer)

What happens:

When I push a change, a file project.git/hooks/git_multimail.pyc is created, but no email is sent.

Doing a configuration test using GIT_MULTIMAIL_CHECK_SETUP=true python git_multimail.py as described on https://github.com/git-multimail/git-multimail/blob/master/doc/troubleshooting.rst tells me that git-multimail seems properly set up

Is there a way to log something like an output of the script? What can I do to find out what is not working? Are there even errors in my files?

Thanks in advance.


Solution

  • Using post-receive.example is by far not the simplest way to set up git_multimail.py: as the header of post-receive.example script says:

    The simplest way to use git-multimail is to use the script git_multimail.py directly as a post-receive hook, and to configure it using Git's configuration files and command-line parameters.

    In other words, just

    cp /path/to/git_multimail.py /path/to/project.git/hooks/post-receive
    

    and you're all set (since you already have project.git/config filled-in). See Invocation in git-multimail's README for a bit more detail.

    (note: admitedly, the doc is not so clear for beginners, I'll try to improve that when I get time)