Possible fix to attachment mail problem (2.0.x)

I think I’ve found where things go wrong, but I don’t have anough of a
global understanding of the code to put a patch together. I figured that
I’d report my findings and see if someone can suggest the right way to fix
what I’m seeing.

The problem that I’m running into relates to mime sent into RT. It gets
parsed correctly and displayed via WebRT, but outgoing mail doesn’t provide
any content at all, even any initial text part.

$Transaction->Content() returns the first MIME object that is associated
with the currnet transaction. It finds them by doing a query on the
Attachments table. It appears that with a non-MIME (or at least
non-multipart) input, there is only one “attachment” and that holds the
message in the content field. In the case of a multipart mime entry
however, the format is a little different. In my test message, I had two
parts. The first was a text part, and the second was a PDF doc. The
Attachments table listed 3 records - the 2nd and 3rd ones were my two
parts, but the 1st one appeared to be just the headers for the message,
with an EMPTY content field. Since that’s the one that is being pulled for
the outgoing email, that’s why the message appears empty.

So, I’m wondering what the right fix is. It seems like the “right” thing
to do would be to be a bit more clever about mailing out MIME, possibly by
iterating over all of the parts and printing them where possible. I’ll try
that first. That aside, is that “header” record in the Attachments table
correct?

I’ll keep poking, but any suggestions are appreciated.
Thanks,
-Matt

Dear Matt,

I think I’ve found where things go wrong, but I don’t have anough of a
global understanding of the code to put a patch together. I figured that
I’d report my findings and see if someone can suggest the right way to fix
what I’m seeing.

The problem that I’m running into relates to mime sent into RT. It gets
parsed correctly and displayed via WebRT, but outgoing mail doesn’t provide
any content at all, even any initial text part.

My Correspondence template looks like this:

{
$Transaction->Attachments(‘text/plain’)->First->Content ||
$Transaction->Attachments(‘text/html’)->First->Content ||
“No Viewable Message.”
}

This (taken from a post here a while ago) should give you at least
some message content.

I have also hacked together a “BounceAll” scrip action (attached).
It will pass on all attachments. Copy into your lib/RT/Action and
update your DB as below.

  1. New scrip action “BounceAll”. We wanted email attachments on
    correspondence to be passed on. BounceAll.pm also removes people
    from To, Cc & Bcc if they were on the To or Cc list of the original
    email. We have $ParseNewMessageForTicketCcs set, which causes email
    Cc’s to be added to RT’s Cc list. When RT sends email out it is
    CC’d to those on the CC list. If the requester happens to
    "reply-to-all", they’ll send a mail to RT and RT’s CC list - when RT
    gets the mail it’ll send yet another copy to everyone on the CC
    list. BounceAll removes these people so that they only get one
    copy. Attached “BounceAll.pm”.
    […]
    You’ll need to update your ScripActions table if you want to use
    these modules, something like:

insert into ScripActions(Name, Description, ExecModule, Argument)
values (“BounceAllWatchers”, “Forward mail to all watchers”,
“BounceAll”, “All”);

insert into ScripActions(Name, Description, ExecModule, Argument)
values (“BounceRequestorsAndCcs”, “Forward mail to requestors”,
“BounceAll”, “Requestor,Cc”);

insert into ScripActions(Name, Description, ExecModule, Argument)
values (“BounceAdminWatchers”, “Forward mail to admin watchers”,
“BounceAll”, “AdminCc”);

Kevin Croombs - Technical Support (support@tao-group.com)
Tao Group (http://www.tao-group.com)

BounceAll.pm (2.7 KB)

Kevin Croombs writes:

This (taken from a post here a while ago) should give you at least
some message content.

Thanks! I missed the fact that attachments could take a type definition.
This is certainly better than no message content at all.

I have also hacked together a “BounceAll” scrip action (attached).
It will pass on all attachments. Copy into your lib/RT/Action and
update your DB as below.

I don’t think I want to use this. For my site, I’d rather just keep one
copy in RT, and email a line something like “[ non-text foofoo.jpg ]” to
indicate that something else was sent.

I’ll keep hacking on the 2nd part, but you’ve certainly taken the
pressure off. Sorry I missed this the 1st time around.
Thanks again,
-Matt

Dear Matt,

[…]

I have also hacked together a “BounceAll” scrip action (attached).
It will pass on all attachments. Copy into your lib/RT/Action and
update your DB as below.

I don’t think I want to use this. For my site, I’d rather just keep one
copy in RT, and email a line something like “[ non-text foofoo.jpg ]” to
indicate that something else was sent.

Rather than poking around the RT core, I’d recommend doing this as a
custom scrip action, otherwise you’ll find it hard to update your
installation. If you want to adapt bounceall, replace the
MIMEObj->attach line with a bit of code that tags “
[ $message->ContentType $message->Filename ]” onto the end of the
message body.

Kevin Croombs - Technical Support (support@tao-group.com)
Tao Group (http://www.tao-group.com)