RT 3.0.8 command line problems

I am trying to process an e-mail using a script (via
procmail) and then call the rt CLI to create the
ticket. The problem is that the text of the text contains
newlines and other possible bad characters. I have escaped
the quotes but I can’t get it to work.

Here’s the code:

    $out .= $body->as_string;
    $out =~ s/\"/\\\"/gs;
    my $arg = "create -t ticket set subject=\"$subject\" set requestor=$requestor set queue=Test set text=\"$out\"";
    system "/opt/rt3/bin/rt $arg";

The error I get is: rt: edit: No variables to set.

I can get it to work by escaping the newlines but I want
my newlines to be preserved.

Can anyone suggest an easy, non-interactive way to get this
to work?