Search code examples
perlsslsvngmailsvn-notify

post-commit mails using gmail (SVN)


I've spent a lot of time yet. But I'm still stuck.

I run Ubuntu 12.04.

I have set up SVN and it's working fine. Now I want to send nice E-Mails on each commit, so I installd svnnotify and applied the --css-inlne patch. (post).

Less secure access is on, I can send E-Mails using phpmailer.

After many hours spent on googleing I ask you.

I've tried the following:

post-commit:

#!/bin/sh

REV=$2
REPO=$1

/usr/local/bin/trac-admin /var/www/trac/htdocs/share changeset added "svn" $REV

# email notifications for commits
/usr/bin/svnnotify --repos-path "$REPO" --revision "$REV"   \
    --smtp          smtp.gmail.com                          \
    --smtp-port     587                                     \
    --smtp-user     [email protected]                     \
    --smtp-pass     pass                                    \
    --smtp-tls                                              \
    --to            [email protected]                      \
    --from          [email protected]                     \
    --with-diff                                             \
    --subject-cx                                            \
    --subject-prefix        'Share: '                       \
    --handler HTML::ColorDiff                               \
    --css-inline
    2>&1 &

exit 0

Results in:

donbolli@luna585:~$ ./post-commit /var/www/svn/share 9
Couldn't start TLS: SSL connect attempt failed because of handshake problems error:1409442E:SSL routines:SSL3_READ_BYTES:tlsv1 alert protocol version
 at /usr/share/perl5/SVN/Notify.pm line 2390.

So I was looking for this error, but found nothing.

So I tried another approach

post-commit:

#!/bin/sh

REV=$2
REPO=$1

/usr/local/bin/trac-admin /var/www/trac/htdocs/share changeset added "svn" $REV

# email notifications for commits
/usr/bin/svnnotify --repos-path "$REPO" --revision "$REV"   \
    --sendmail      /home/donbolli/sendmail.py              \
    --to            [email protected]          \
    --from          [email protected]                     \
    --with-diff                                             \
    --subject-cx                                            \
    --subject-prefix        'Share: '                       \
    --handler HTML::ColorDiff                               \
    --css-inline
    2>&1 &

exit 0

Results in

donbolli@luna585:~$ ./post-commit /var/www/svn/share 9
Can't exec "/home/donbolli/sendmail.py": No such file or directory at /usr/share/perl5/SVN/Notify.pm line 2332.
Cannot exec /home/donbolli/sendmail.py: No such file or directory

But the file exists (and is 755)

donbolli@luna585:~$ cat /home/donbolli/sendmail.py
#!/usr/bin/perl
use MIME::Lite;
use Net::SMTPS;

my $msg = MIME::Lite ->new (
From => '[email protected]',
To => '[email protected]',
Type => 'text/html; charset=UTF-8'
);

...

Solution

  • my post-commit;

    #!/bin/sh
    
    REV=$2
    REPO=$1
    
    /usr/local/bin/trac-admin /var/www/trac/htdocs/share changeset added "svn" $REV
    
    # email notifications for commits
    /usr/bin/svnnotify --repos-path "$REPO" --revision "$REV" 	\
    	--sendmail		/usr/sbin/sendmail						\
    	--to			[email protected]      				\
        --from			[email protected]						\
        --with-diff												\
        --subject-cx											\
        --subject-prefix		'Share: '						\
        --handler HTML::ColorDiff								\
        --css-inline
        2>&1 &
    
    exit 0

    Works after I followed the sendmail instructions.

    Thanks to xxfelixxx

    install sendmail