简体   繁体   English

在Fossil修改机票时发送电子邮件通知

[英]Email notification upon ticket modification in Fossil

I need to receive an email notification whenever a user creates a ticket or a ticket gets updated. 每当用户创建故障单或故障单更新时,我都需要收到电子邮件通知。 Fossil has something called ticket hook, which is accessible in the UI from admin -> transfers -> Ticket . Fossil有一个名为ticket hook的东西,可以在UI中从admin -> transfers -> Ticket I have tried the following code from here : 我从这里尝试了以下代码:

set project simpletask
tclInvoke package require http
query {SELECT title, status
        FROM ticket
        WHERE tkt_uuid=$uuid} {
   set title [tclInvoke http::formatQuery  $title]
   http -asynchronous -- http://127.0.0.1/cgi-bin/tkt-hook?uuid=$uuid&title=$title&status=$status&project=$project
}

I expect this code to be executed once a ticket is modified, but I don't really know how to modify it to send an email, and how I can specify to whom the email should be sent to. 我希望修改故障单后执行此代码,但我真的不知道如何修改它以发送电子邮件,以及如何指定电子邮件应发送给谁。

Does anyone have a sample TH1 code for sending email notifications that can share? 有没有人有一个样本TH1代码用于发送可以共享的电子邮件通知?

TH1 is not able to do this on its own; TH1不能单独执行此操作; it's too limited (and deliberately so). 它太有限了(故意如此)。 If you've got invocation of Tcl enabled in TH1 (it's not enabled by default) then you can use something like: 如果您在TH1中启用了Tcl调用(默认情况下未启用),那么您可以使用以下内容:

### THIS IS TH1 ###
tclInvoke source /some/dir/scripts/emailsender.tcl
query {SELECT title, status
       FROM ticket
       WHERE tkt_uuid=$uuid} {
    tclInvoke send_email $title $status $uuid
}

Then you just need to make sure that your emailsender.tcl script (in the above location) defines a procedure send_email that does what you want. 然后,您只需要确保您的emailsender.tcl脚本(在上面的位置)定义了一个可以执行您想要的过程send_email You're talking about something like this: 你在谈论这样的事情:

### THIS IS TCL ###
package require mime
package require smtp

# Where to route messages through; IMPORTANT!
variable smtp_host smtp.example.com

proc send_email {title status uuid} {
    variable smtp_host
    set t [mime::initialize -canonical text/plain \
            -string "state is now $status for $uuid"]
    mime::setheader $t Subject "Change to '$title'"
    smtp::sendmessage $t -recipients you@example.com -servers $smtp_host
    mime::finalize $t
}

You'll need to pass across more fields, insert more logic to generate a message, choose who to send the message to (a mailing list is a good start!) and so on, but that's the core of it all. 您需要传递更多字段,插入更多逻辑来生成消息,选择将消息发送给谁(邮件列表是一个好的开始!)等等,但这就是它的核心。 You may also need to explicitly lappend the directory containing the Tcllib packages to the global auto_path ; 您可能还需要将包含Tcllib包的目录显式地lappend到全局auto_path ; that script is going to be very specific to your configuration. 该脚本将非常特定于您的配置。


Or you could make a script that listens to that port you push a notification to using the sample script and work with that. 或者您可以创建一个侦听该端口的脚本,您可以使用示例脚本推送通知并使用该脚本。 That would be easier to abuse though; 但这会更容易被滥用; not recommended. 不建议。

I just followed IFTTT approach, where we used IFTTT service to connect rss feed of Fossil scm to Gmail channel. 我只是遵循IFTTT方法,我们使用IFTTT服务将Fossil scm的rss feed连接到Gmail频道。 It worked. 有效。

Please refer: http://lists.fossil-scm.org:8080/pipermail/fossil-users/2013-August/013330.html https://ifttt.com/recipes/109526 请参考: http//lists.fossil-scm.org8080 / pipermail / fossil-usersrs / 2013-August/013330.html https://ifttt.com/recipes/109526

https://ifttt.com/recipes/109526 --> is for email notification for New ticket, that can be modified (change keyword or simple phrase) to send email for any ticket modification. https://ifttt.com/recipes/109526 - >用于新票证的电子邮件通知,可以修改(更改关键字或简单短语)以发送任何故障单修改的电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM