5
# Nick Barnes, Ravenbrook Limited, 2004-04-01.
7
# $Id: sendbugmail.pl,v 1.7 2006/07/03 21:42:47 mkanat%bugzilla.org Exp $
9
# Bugzilla email script for Bugzilla 2.17.4 and later. Invoke this to send
10
# bugmail for a bug which has been changed directly in the database.
11
# This uses Bugzilla's own BugMail facility, and will email the
12
# users associated with the bug. Replaces the old "processmail"
15
# Usage: perl -T contrib/sendbugmail.pl bug_id user_email
21
use Bugzilla::BugMail;
24
my $dbh = Bugzilla->dbh;
27
print STDERR "Usage: $0 bug_id user_email\n";
31
if (($#ARGV < 1) || ($#ARGV > 2)) {
36
my $bugnum = $ARGV[0];
37
my $changer = $ARGV[1];
39
# Validate the bug number.
40
if (!($bugnum =~ /^(\d+)$/)) {
41
print STDERR "Bug number \"$bugnum\" not numeric.\n";
45
detaint_natural($bugnum);
47
my ($id) = $dbh->selectrow_array("SELECT bug_id FROM bugs WHERE bug_id = ?",
51
print STDERR "Bug number $bugnum does not exist.\n";
55
# Validate the changer address.
56
my $match = Bugzilla->params->{'emailregexp'};
57
if ($changer !~ /$match/) {
58
print STDERR "Changer \"$changer\" doesn't match email regular expression.\n";
61
if(!login_to_id($changer)) {
62
print STDERR "\"$changer\" is not a login ID.\n";
67
my $outputref = Bugzilla::BugMail::Send($bugnum, {'changer' => $changer });
70
my $sent = scalar(@{$outputref->{sent}});
71
my $excluded = scalar(@{$outputref->{excluded}});
74
print "email sent to $sent recipients:\n";
76
print "No email sent.\n";
79
foreach my $sent (@{$outputref->{sent}}) {
84
print "$excluded recipients excluded:\n";
86
print "No recipients excluded.\n";
89
foreach my $excluded (@{$outputref->{excluded}}) {
93
# This document is copyright (C) 2004 Perforce Software, Inc. All rights
96
# Redistribution and use of this document in any form, with or without
97
# modification, is permitted provided that redistributions of this
98
# document retain the above copyright notice, this condition and the
99
# following disclaimer.
101
# THIS DOCUMENT IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
102
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
103
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
104
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
105
# HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
106
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
107
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
108
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
109
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
110
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
111
# DOCUMENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.