HomeGeneralScriptsHow do I send an email when a review has been accepted/rejected?

14.3. How do I send an email when a review has been accepted/rejected?

The 'OnIssueAction' repository script could be used to send an email when handling issues. OnIssueAction() is called whenever an action is performed on an issue.Here is an example of how we send e-mails from a repository script ..

import smtplib

def OnIssueAction(issue,action,user,email,description):
     TEXT = "Description\r\n===========\r\n%s\r\n" % (description)
    ADDRESS_TO = [email]
    SMTP_SERVER = 'mailscanner.purecm.com'
    ADDRESS_FROM = 'purecm@purecm.com'
    SUBJECT = '[%s] %s has been assigned to you' % (gethostname(),issue)
    MESSAGE = "From: %s\r\nTo: %s\r\nSubject:%s\r\n%s\r\n" % (ADDRESS_FROM, ADDRESS_TO, SUBJECT, TEXT)
    server = smtplib.SMTP(SMTP_SERVER)
    server.login('user','password')
    server.sendmail(ADDRESS_FROM, ADDRESS_TO, MESSAGE)
    server.quit()
    return

If you only want to send an email for specific actions you can check the 'action' parameter which is the action name.

If you want to do more complex processing (e.g. send an email to all users within the group) then you should use a trigger with either the .NET or Java API.

 

This page was: Helpful | Not Helpful