in reply to Sorting and deleting spam emails in the RT queue

Perhaps you'd like to give us enough information to understand what you're actually trying to do... and how. I know what I mean. Why don't you? Something like code and data. How do I post a question effectively? Something like an explanation of "resource Tracker" On asking for help (and how this is a Perl question).

Then do the really hard stuff... like tell us how you define an email as spam. Without that, you've just sent us something that's about as welcome as p0rn ads to the parish email account.

But I can answer one question, "(i)s there any easy way of writing the script?" (question mark supplied; missing in the OP): "yes, but you have to know data specifics and be familiar with an appropriate language."

  • Comment on Re: Sorting and deleting spam emails in the RT queue

Replies are listed 'Best First'.
Re^2: Sorting and deleting spam emails in the RT queue
by brainfold (Initiate) on Dec 15, 2010 at 04:40 UTC

    Dear Monk,

    Apologise for the unlcear question and thank you for your time in replying. Here what i am trying to do.

    Recently we have started using Resource tracker to sort the incoming emails and assign it to different teams. Say with the key word in the subject we are sorting the emails from general to different queue names.

    Now i want to write a script to delete messages in the queue with specific "Key words" or specific email address it came from. So the two variables are array of 'key words' and array of 'to address'.

    I am using this below script to categorise them as "messages to be deleted" and manually deleting it.

    for example,


    <c> my $match = ".*weekly message.*"; my $t_subject = $self->TicketObj->Subject; if ( $t_subject !~ /$match/i ) { return 0; } else { return 1; } my $newqueue = "To be deleted"; my $T_Obj = $self->TicketObj; $RT::Logger->info("Auto assign ticket #". $T_Obj->id ." to queue #". $newqueue ); my ($status, $msg) = $T_Obj->SetQueue($newqueue); unless ($status) { $RT::Logger->warning("unable to set new queue: $msg"); return undef; } return 1; </code>

    But would like to code a script that could delete those emails within the key word ranhe automatically..

    Thanks

Re^2: Sorting and deleting spam emails in the RT queue
by brainfold (Initiate) on Dec 15, 2010 at 06:07 UTC
    Dear Monks,

    Thank you for support., finally i have found a way of deleting the incoming message with the specific subject..


    code as below

    In the Custom condition specify the transactions that are Type:Correspond (e-mail) and that have "weekly" in the subject. The custom condition could look something like this:


    { my $Transaction = $self->TransactionObj; return $Transaction->Type eq 'Correspond' && $Transaction->Subject =~ +/weekly/; }

    In the Custom action preparation code area specify:


    return 1;

    In the Custom action cleanup code area specify something like this:</P

    my $Ticket = $self->TicketObj; $Ticket->SetStatus('resolved'); return 1;
Re^2: Sorting and deleting spam emails in the RT queue
by brainfold (Initiate) on Dec 15, 2010 at 04:37 UTC
    Dear Monk, Apologise for the unlcear question and thank you for your time in replying. Here what i am trying to do. Recently we have started using Resource tracker to sort the incoming emails and assign it to different teams. Say with the key word in the subject we are sorting the emails from general to different queue names. Now i want to write a script to delete messages in the queue with specific "Key words" or specific email address it came from. So the two variables are array of 'key words' and array of 'to address'. I am using this below script to categorise them as "messages to be deleted" and manually deleting it. for example, my $match = ".*weekly message.*"; my $t_subject = $self->TicketObj->Subject; if ( $t_subject !~ /$match/i ) { return 0; } else { return 1; } my $newqueue = "To be deleted"; my $T_Obj = $self->TicketObj; $RT::Logger->info("Auto assign ticket #". $T_Obj->id ." to queue #". $newqueue ); my ($status, $msg) = $T_Obj->SetQueue($newqueue); unless ($status) { $RT::Logger->warning("unable to set new queue: $msg"); return undef; } return 1; But would like to code a script that could delete those emails within the key word ranhe automatically.. Thanks

      brainfold:

      First, my habitual reminder: Please use code tags! It's really easy: <c>Code goes here</c> see? This is what your post could look like with them:

      my $match = ".*weekly message.*"; my $t_subject = $self->TicketObj->Subject; if ( $t_subject !~ /$match/i ) { return 0; } else { return 1; } my $newqueue = "To be deleted"; my $T_Obj = $self->TicketObj; $RT::Logger->info("Auto assign ticket #". $T_Obj->id ." to queue #". $ +newqueue ); my ($status, $msg) = $T_Obj->SetQueue($newqueue); unless ($status) { $RT::Logger->warning("unable to set new queue: $msg"); return undef; } return 1;

      Anyway, I just wanted to mention that if you're not using the beginning of line (^) or end of line ($) anchors, your use of .* is irrelevant.

      And now, on to yur question. I interpret it to mean "OK, now that I've identified which EMails I need to delete, how do I do it automatically?" If that's the correct question, then I'd have to reply with: What package/module are you using to talk with your EMail queue? It may have the methods you want. I'm nearly certain that if your EMail server provides IMAP that there's a module that will let you delete individual messages.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

      Update: I see that you're using code tags properly later in the thread. Did you know that since you're logged in you can go back and update a post? That way, when you do something like figure out how code tags work, or want to improve a question to get better responses, you can do so.