<%ARGS> $From => undef $Group => undef $Subject => undef $Message => undef $Send => undef $result => undef <& /Elements/Header, Title => 'Broadcast Message' &> <& /Elements/Tabs &>
% if ($result) {
Results

% $m->out( $result );

% }
<&| /Widgets/TitleBox, title => loc('Broadcast Message') &>

<&|/l&>From: | <& /Elements/EmailInput, Name => 'From', Size => '40', Default => $ARGS{From} || $session{CurrentUser}->EmailAddress &>
<&|/l&>Group: | <& /Search/Elements/SelectGroup, Name => 'Group', Default => $ARGS{Group} &>
<&|/l&>Subject: |
<&|/l&>Message: | <% $Message %>

<& /Elements/Submit, Label => loc('Send'), Name => 'Send' &>
<%INIT> use Encode; use MIME::Entity; use RT::Interface::Email; # /Admin/autohandler does this - but it never hurts to double check :) if (! $session{'CurrentUser'}->UserObj->HasRight( Right => 'ShowConfigTab', Object => $RT::System ) ) { $m->out("You don't have permissions to view this page"); return; } # # Send out a group email. # if ($Send) { if ($From && $Group && $Subject && $Message) { my $group_obj = RT::Group->new( $RT::SystemUser ); $group_obj->LoadUserDefinedGroup( $Group ); my @emails = $group_obj->MemberEmailAddresses; my $To = join(', ', @emails); my $mime = MIME::Entity->build( 'From' => Encode::encode_utf8($From), 'To' => Encode::encode_utf8($From), 'Bcc' => Encode::encode_utf8($To), 'Subject' => Encode::encode_utf8($Subject), 'Data' => Encode::encode_utf8($Message) ); my $ok = RT::Interface::Email::SendEmail( Entity => $mime ); $result .= "You sucessfully sent your message to ". scalar(@emails) . " users:\n"; $result .= join "\n", map { "
- $_
" } @emails; } else { $result = "Error: You must enter all fields to broadcast"; } } # vim: syn=mason