On create, send email only during time window?

Right now, I am using this code to send an email to the group of people that are part of a group.

I want to add another user to the group, but only want that user to get an email from 7pm to 7am m-f, and all day Sat & Sun.

Can anyone help me out with this? Thanks! We want to create an email address for an on-call email box.

-Mark

To: {
my $GroupName = ‘HelpDesk’;

instantiate a group object

my $addGroupObj = RT::Group->new($RT::SystemUser);
$addGroupObj->LoadUserDefinedGroup($GroupName);
return undef unless $addGroupObj;
my $addGroupMembersObj = $addGroupObj->UserMembersObj;

my $res = ‘’;

walk through members of group

while ( my $userObj = $addGroupMembersObj->Next) {
my $email = $userObj->EmailAddress;
next unless $email; # email can be empty

 $res .= ', ' if $res;
 $res .= $email;

}
$res;
}

Mark Jenks
Network Administrator
[IOD Incorporated E-Mail Signature Graphic 02-21-11]
1030 Ontario Road Green Bay, WI 54311 p: 920.406.3702

mark.jenks@iodincorporated.commailto:mark.jenks@iodincorporated.com

Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy
laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from
retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have
received this communication in error, and then immediately delete it. Thank you in advance for your cooperation

Right now, I am using this code to send an email to the group of people that are part of a group.

You could probably replace 80% of this code with a call to
MemberEmailAddresses which you can find in Group_Overlay.pm

I want to add another user to the group, but only want that user to get an email from 7pm to 7am m-f, and all day Sat & Sun.

You have 2 options, cron job to add/remove that email from the group
or some date logic using either DateTime or RT::Date. The DateTime
man page should have docs on how to find out the time of day.

There is also the Business::Hours CPAN module which you can probably
find examples of folks using in the mailing list archives or the wiki
or RTIR. That lets you figure out if you’re in or out of business
hours to add that extra email address.

-kevin