[rt-users] On create, send email only during time window?

Kevin Falcone falcone at bestpractical.com
Mon May 16 12:15:53 EDT 2011


On Fri, May 13, 2011 at 07:20:00PM +0000, Mark Jenks wrote:
> 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

> 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;
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110516/5f4a2db7/attachment.sig>


More information about the rt-users mailing list