Wednesday, December 16, 2009

Use gmail smtp server for post commit notifications in Subversion via

In my previous post I described how to enable conditional post commit notifications in Subversion. In this post I’m going to show how to extend from subversion tools in order to use gmail smtp server ( for sending emails.

You should note one thing if you want to use gmail smtp server for emailing in your applications – it requires SSL enabled. So first you need to create gmail account – its credentials will be used to connect to  Once gmail account created you need to add new setting “smtp_use_ssl” in mailer.conf file:

   1: [general]
   3: smtp_hostname =
   4: smtp_username = your_gmail_login
   5: smtp_password = your_gmail_password
   7: # 2009-12-13 asadomov: add custom smtp_use_ssl parameter
   8: smtp_use_ssl = true
   9: ...
Next you need to modify SMTPOutput class in in order to use added “smtp_use_ssl” setting:
   1: class SMTPOutput(MailedOutput):
   2:   "Deliver a mail message to an MTA using SMTP."
   4:   def start(self, group, params):
   5:     MailedOutput.start(self, group, params)
   7:     self.buffer = StringIO()
   8:     self.write = self.buffer.write
  10:     self.write(self.mail_headers(group, params))
  12:   def finish(self):
  13:     server = smtplib.SMTP(self.cfg.general.smtp_hostname)
  15:     # 2009-12-13 asadomov: add ssl configuration (e.g. for gmail smtp server)
  16:     if self.cfg.is_set('general.smtp_use_ssl') and self.cfg.general.smtp_use_ssl.lower() == "true":
  17:       server.ehlo()
  18:       server.starttls()
  19:       server.ehlo()
  21:     if self.cfg.is_set('general.smtp_username'):
  22:       server.login(self.cfg.general.smtp_username,
  23:                    self.cfg.general.smtp_password)
  24:     server.sendmail(self.from_addr, self.to_addrs, self.buffer.getvalue())
  25:     server.quit()

After that you will be able to use gmail smtp server to send post commit notifications via


  1. Replies
    1. Hi All!

      I'm selling fresh & genuine SSN Leads, with good connectivity. All data properly checked & verified.
      Headers in Leads:

      First Name | Last Name | SSN | Dob | Address | State | City | Zip | Phone Number | Account Number | Bank Name | DL Number | Routing Number | IP Address | Reference | Email | Rental/Owner |

      *You can ask for sample before any deal
      *Each lead will be cost $1
      *Premium Lead will be cost $5
      *If anyone wants in bulk I will negotiate
      *Sampling is just for serious buyers

      Hope for the long term deal
      For detailed information please contact me on:

      Whatsapp > +923172721122
      email >
      telegram > @leadsupplier
      ICQ > 752822040

  2. how can i use another smtp server as ssmtp with
    or how can i configure sendmail to send mails via gmail?

  3. sunevil hi,
    for your 1st question: as I showed in the post, in order to specify what smtp server should be used by, you need to set the following settings:

    smtp_hostname = server_name:port
    smtp_username = login
    smtp_password = password

    in the mailer.conf file.
    For 2nd question: this post exactly shows how to configure to send mails via gmail.

  4. Hi Alex,
    Short: Is there any option to insert %(author)s resolution by openLDAP to mailer.conf file?
    Detailed: I running subversion 1.6.11 which authenticates users by OpenLDAP. I want to send email notifications to each user upon he/she makes commit.

  5. Hi rugb,
    I didn't use LDAP for svn authentication, so can't help much here. If you need to send email notification to the author of the commit, I think you need to perform 2 actions:
    1. catch commit event
    2. determine email of the author
    Is it so that you have problems with 2nd step?

  6. Hi Alex how to add repository name


    Repositoryname: Demo
    Author: Jhon
    Version: 143

  7. running file
    error : You need version 1.8.1 or better of the Subversion Python bindings.