JIRA - 向匿名用户发送电子邮件

发布于 2024-12-07 04:18:08 字数 730 浏览 1 评论 0 原文

我正在尝试找出一种方法,当用户通过电子邮件创建问题时,向匿名用户发送电子邮件。我需要的是让这个匿名用户在问题打开、评论和关闭时收到通知电子邮件。 根据他们的官方文档,这只能如果创建者已经是 JIRA 中的用户或者将动态创建用户,则需要完成此操作。这些都不适合我。 到目前为止,我找到的解决方法是:

  1. JEMH - 它承诺了此功能,但看起来不稳定,这意味着每次 JIRA 更新时它似乎都会中断(至少有一点点),并且我不能接受任何停机时间。
  2. 按照 类似的线程

我编写自己的脚本没有问题,但我只是想确保我不会重新发明轮子。还有其他方法可以做到这一点吗?

如果有任何帮助,我将非常感激。

I'm trying to figure out a way to send an email to an anonymous user when one creates an issue through the email. What I need is for this anonymous user to receive a notification email when the issue was opened,commented and closed.
According to their official documentation this can only be done if the creator is already a user in JIRA or if a user will be created on the fly. None of which works for me.
The work-arounds that I found so far are:

  1. JEMH - which promises this functionality but looks unstable, meaning it seems to break (at least for a little bit) with every JIRA update and no downtime is acceptable for me.
  2. Writing my own script as was recommended in the similar thread

I have no problems writing my own script but I just wanted to be sure I won't be reinventing the wheel. Are there any other ways of doing this?

I'll be very greatful for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

楠木可依 2024-12-14 04:18:08

我刚刚注意到这个问题。 JEMH 现在已经发展成为一个成熟的商业插件,并拥有大量新功能,其中一些功能实际上解决了支持远程“匿名”用户创建问题的问题,从本质上将 JIRA 转变为功能齐全的电子邮件帮助台解决方案。针对每个事件,可以进行特定的模板定制。

关于损坏,停留在“最新”版本让开发人员绝对没有时间赶上。聪明地玩,给所有开发者一个赶上的机会。

不幸的是,随着 JEMH 深入研究 JIRA API,损坏很常见,但由于 Atlassian 在 5.0+ 中稳定了一些核心 API,现在这种情况不太可能发生。提供端到端集成测试的工作也在进行中,这本身就是一项使命!

I just noticed this question. JEMH has now evolved into a fully fledged commercial plugin, and has a mass of new features, some of which actually address supporting remote 'anonymous' users for issue creation, essentially turning JIRA into a fully capable email helpdesk solution. Specific template customization is available for this on a per-event basis.

Regarding breakages, staying at the 'latest' release gives developers absolutely no time to catchup. Play smart, give all developers a chance to catchup.

With the depths of JIRA API's that JEMH plumbs, breakages were unfortunately common, but now are less likely thanks to Atlassian stabilizing some core API's in 5.0+. Work also also underway to provide end-end integration testing, which is a mission in its own right!

风吹过旳痕迹 2024-12-14 04:18:08

这是我使用 Script Runner 插件 完成此操作的方法,我已告诉 Jira 从我的邮箱中获取电子邮件,并从中创建问题。然后,在工作流程中,我使用以下脚本将发件人的电子邮件和姓名保存到自定义字段:

from com.atlassian.jira import ComponentManager
import re
cfm = ComponentManager.getInstance().getCustomFieldManager()

# read issue description
description = issue.getDescription()
if (description is not None) and ('Created via e-mail received from' in description):
    # extract email and name:
    if ('<' in description) and ('>' in description):
        # pattern [Created via e-mail received from: name <[email protected]>]
        # split it to a list
        description_list = re.split('<|>|:',description)
        list_length = len(description_list)
        for index in range(list_length-1, -1, -1):
            if '@' in description_list[index]:
                customer_email = description_list[index]
                customer_name = description_list[index - 1]
                break
    else:
        # pattern [Created via e-mail received from: [email protected]]
        customer_name = "Sir or Madam"
        # split it to a list  
        description_list = re.split(': |]',description)
        list_length = len(description_list)
        for index in range(list_length-1, -1, -1):
            if '@' in description_list[index]:
                customer_email = description_list[index]
                break

    # if the name isn't in the right form, switch it's places:
    if (customer_name[0] == '"') and (customer_name[-1] == '"') and (',' in customer_name):
        customer_name = customer_name[1:-1]
        i =  customer_name.index(',')
        customer_name = customer_name[i+2:]+" "+customer_name[:i]

    # insert data to issue fields
    issue.setCustomFieldValue(cfm.getCustomFieldObject("customfield_10401"),customer_email)
    issue.setCustomFieldValue(cfm.getCustomFieldObject("customfield_10108"),customer_name)

然后,使用以下脚本发送邮件:

import smtplib,email
from smtplib import SMTP 
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
import re
from com.atlassian.jira import ComponentManager

customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
cfm = ComponentManager.getInstance().getCustomFieldManager()

# read needed fields from the issue
key = issue.getKey()
#status = issue.getStatusObject().name
summary = issue.getSummary()
project = issue.getProjectObject().name

# read customer email address
toAddr = issue.getCustomFieldValue(cfm.getCustomFieldObject("customfield_10401"))
# send mail only if a valid email was entered
if (toAddr is not None) and (re.match('[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,4}',toAddr)):
    # read customer name
    customerName = issue.getCustomFieldValue(cfm.getCustomFieldObject("customfield_10108"))
    # read template from the disk
    template_file = 'new_case.template'
    f = open(template_file, 'r')
    htmlBody = ""
    for line in f:
        line = line.replace('$CUSTOMER_NAME',customerName)
        line = line.replace('$KEY',key)
        line = line.replace('$PROJECT',project)
        line = line.replace('$SUMMARY',summary)
        htmlBody += line + '<BR>'


    smtpserver = 'smtpserver.com'
    to = [toAddr]
    fromAddr = '[email protected]'
    subject = "["+key+"] Thank You for Contacting Support team"
    mail_user = '[email protected]'
    mail_password = 'password'

    # create html email
    html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
    html +='"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'
    html +='<body style="font-size:12px;font-family:Verdana">'
    html +='<p align="center"><img src="http://path/to/company_logo.jpg" alt="logo"></p> '
    html +='<p>'+htmlBody+'</p>'
    html +='</body></html>'

    emailMsg = email.MIMEMultipart.MIMEMultipart('alternative')
    emailMsg['Subject'] = subject
    emailMsg['From'] = fromAddr
    emailMsg['To'] = ', '.join(to)
    emailMsg.attach(email.mime.text.MIMEText(html,'html'))

    # Send the email
    s = SMTP(smtpserver) # ip or domain name of smtp server
    s.login(mail_user, mail_password)   
    s.sendmail(fromAddr, [to], emailMsg.as_string())
    s.quit()

    # add sent mail to comments
    cm = ComponentManager.getInstance().getCommentManager()
    email_body = htmlBody.replace('<BR>','\n')
    cm.create(issue,'anonymous','Email was sent to the customer ; Subject: '+subject+'\n'+email_body,False)

new_case.template 的内容:

Dear $CUSTOMER_NAME,

Thank you for contacting support team.

We will address your case as soon as possible and respond with a solution very quickly.

Issue key $KEY has been created as a reference for future correspondence.

If you need urgent support please refer to our Frequently Asked Questions page at http://www.example.com/faq.

Thank you,

Support Team


Issue key: $KEY
Issue subject: $PROJECT
Issue summary: $SUMMARY

应附加所有脚本到工作流程,到 Create 转换。脚本是使用 Jython 编写的,所以需要安装使用它。

Here is how I did it using the Script Runner pluging, I've told Jira to get emails from my mailbox, and create issues from them. Than, on the workflow, I saved the sender's email and name to a custom fields using the following script:

from com.atlassian.jira import ComponentManager
import re
cfm = ComponentManager.getInstance().getCustomFieldManager()

# read issue description
description = issue.getDescription()
if (description is not None) and ('Created via e-mail received from' in description):
    # extract email and name:
    if ('<' in description) and ('>' in description):
        # pattern [Created via e-mail received from: name <[email protected]>]
        # split it to a list
        description_list = re.split('<|>|:',description)
        list_length = len(description_list)
        for index in range(list_length-1, -1, -1):
            if '@' in description_list[index]:
                customer_email = description_list[index]
                customer_name = description_list[index - 1]
                break
    else:
        # pattern [Created via e-mail received from: [email protected]]
        customer_name = "Sir or Madam"
        # split it to a list  
        description_list = re.split(': |]',description)
        list_length = len(description_list)
        for index in range(list_length-1, -1, -1):
            if '@' in description_list[index]:
                customer_email = description_list[index]
                break

    # if the name isn't in the right form, switch it's places:
    if (customer_name[0] == '"') and (customer_name[-1] == '"') and (',' in customer_name):
        customer_name = customer_name[1:-1]
        i =  customer_name.index(',')
        customer_name = customer_name[i+2:]+" "+customer_name[:i]

    # insert data to issue fields
    issue.setCustomFieldValue(cfm.getCustomFieldObject("customfield_10401"),customer_email)
    issue.setCustomFieldValue(cfm.getCustomFieldObject("customfield_10108"),customer_name)

than, send the mail using the following script:

import smtplib,email
from smtplib import SMTP 
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
import re
from com.atlassian.jira import ComponentManager

customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
cfm = ComponentManager.getInstance().getCustomFieldManager()

# read needed fields from the issue
key = issue.getKey()
#status = issue.getStatusObject().name
summary = issue.getSummary()
project = issue.getProjectObject().name

# read customer email address
toAddr = issue.getCustomFieldValue(cfm.getCustomFieldObject("customfield_10401"))
# send mail only if a valid email was entered
if (toAddr is not None) and (re.match('[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,4}',toAddr)):
    # read customer name
    customerName = issue.getCustomFieldValue(cfm.getCustomFieldObject("customfield_10108"))
    # read template from the disk
    template_file = 'new_case.template'
    f = open(template_file, 'r')
    htmlBody = ""
    for line in f:
        line = line.replace('$CUSTOMER_NAME',customerName)
        line = line.replace('$KEY',key)
        line = line.replace('$PROJECT',project)
        line = line.replace('$SUMMARY',summary)
        htmlBody += line + '<BR>'


    smtpserver = 'smtpserver.com'
    to = [toAddr]
    fromAddr = '[email protected]'
    subject = "["+key+"] Thank You for Contacting Support team"
    mail_user = '[email protected]'
    mail_password = 'password'

    # create html email
    html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
    html +='"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'
    html +='<body style="font-size:12px;font-family:Verdana">'
    html +='<p align="center"><img src="http://path/to/company_logo.jpg" alt="logo"></p> '
    html +='<p>'+htmlBody+'</p>'
    html +='</body></html>'

    emailMsg = email.MIMEMultipart.MIMEMultipart('alternative')
    emailMsg['Subject'] = subject
    emailMsg['From'] = fromAddr
    emailMsg['To'] = ', '.join(to)
    emailMsg.attach(email.mime.text.MIMEText(html,'html'))

    # Send the email
    s = SMTP(smtpserver) # ip or domain name of smtp server
    s.login(mail_user, mail_password)   
    s.sendmail(fromAddr, [to], emailMsg.as_string())
    s.quit()

    # add sent mail to comments
    cm = ComponentManager.getInstance().getCommentManager()
    email_body = htmlBody.replace('<BR>','\n')
    cm.create(issue,'anonymous','Email was sent to the customer ; Subject: '+subject+'\n'+email_body,False)

content of new_case.template:

Dear $CUSTOMER_NAME,

Thank you for contacting support team.

We will address your case as soon as possible and respond with a solution very quickly.

Issue key $KEY has been created as a reference for future correspondence.

If you need urgent support please refer to our Frequently Asked Questions page at http://www.example.com/faq.

Thank you,

Support Team


Issue key: $KEY
Issue subject: $PROJECT
Issue summary: $SUMMARY

All scripts should be attach to the workflow, to Create transition.The scripts are written using Jython, so it needs to be installed to use it.

不弃不离 2024-12-14 04:18:08

我怀疑 JIRA 中是否已经内置了此功能,而且我还没有看到可以执行此操作的插件。

我过去研究过这个问题,结果却一无所获。我怀疑它不是内置的,因为对于许多潜在客户来说,这将允许他们获得 10 个用户许可证,但仍然支持数千个用户。

我们选择了无限用户许可证。

更新:我想补充一点,你可以编写一个脚本来执行此操作,我想。但它看起来像是一个 PITA,必须为其创建一个自定义侦听器来捕获问题的更改 https://developer.atlassian.com/display/DOCS/Plugin+Tutorial+-+Writing+event+listeners+with+the+atlassian-event+library

I doubt this functionality is available already built-in to JIRA, and I have not seen a plugin that will do it.

I looked into this in the past and came up empty. I suspect it is not built in because for many potential customers it would allow them to get away with a 10 user license and yet still support thousands of users.

We went with the unlimited user license instead.

Update: I meant to add to this that you could write a script that would do this, I think. But it looks like it would be a PITA with having to create a custom listener for it to capture changes to the issue https://developer.atlassian.com/display/DOCS/Plugin+Tutorial+-+Writing+event+listeners+with+the+atlassian-event+library

舂唻埖巳落 2024-12-14 04:18:08

您可以使用 Raley 电子邮件通知
配置很简单,下面是如何执行此操作的示例:
https://wiki。 raleyapps.com/display/RAL/Sending+email+to+value+from+JIRA+issue+custom+field

You can send notification to email stored in Jira custom field using Raley Email Notifications
The configuration is trivial, here's an example how to do it:
https://wiki.raleyapps.com/display/RAL/Sending+email+to+value+from+JIRA+issue+custom+field

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文