to follow up on this, to re-write the body of an email completely you
can do this:

$transaction->body_resetpos;
truncate $transaction->body_fh(), 0;
$transaction->body_rewrite( $newbody);


On 29 December 2010 21:34, Ryszard <ryszar...@gmail.com> wrote:
> Maybe a waste of time for you, but worked wonders for me after using google
> for hours looking for a solution that worked for me, and finding nothing.
>
> On 29/12/2010 9:16 PM, <qpsmtpdfrose.20.ftu...@spamgourmet.com> wrote:
>>
>> Ryszard - ryszar...@gmail.com wrote:
>>
>> This is a total waste of time. I already explained, it is possible to do
>> it with the existing module.
>> Try looking in the archives. Someone sent me an email with an example in
>> it, iirc.
>>
>>> after many attempts at rewriting the body (and not just appending to
>>> the end), i couldnt work it out.  So, to work around the problem, i've
>>> created a new method called body_rewrite. please find below a patch
>>> for the new method:
>>> ----------8<---------------------------------------
>>>
>>> --- Transaction.pm      2010-12-28 09:27:23.000000000 +1100
>>> +++ Transaction.pm.new  2010-12-28 09:23:30.000000000 +1100
>>> @@ -151,6 +151,38 @@
>>>   }
>>>  }
>>>
>>> +sub body_rewrite {
>>> +  my $self = shift;
>>> +  my $data = shift;
>>> +  if ($self->{_body_file}) {
>>> +    #warn("body_rewrite to file\n");
>>> +    # go to the end of the file
>>> +    seek($self->{_body_file},0,1)
>>> +      unless $self->{_body_file_writing};
>>> +    $self->{_body_file_writing} = 1;
>>> +    $self->{_body_file}->print(ref $data eq "SCALAR" ? $$data : $data)
>>> +      and $self->{_body_size} += length (ref $data eq "SCALAR" ?
>>> $$data : $data);
>>> +  }
>>> +  else {
>>> +    #warn("body_rewrite to array\n");
>>> +    $self->log(LOGWARN, "DEBUG: body_rewrite to array");
>>> +    $self->{_body_array} = [];
>>> +    my $ref = ref($data) eq "SCALAR" ? $data : \$data;
>>> +    pos($$ref) = 0;
>>> +    while ($$ref =~ m/\G(.*?\n)/gc) {
>>> +      push @{ $self->{_body_array} }, $1;
>>> +      $self->{_body_size} += length($1);
>>> +      ++$self->{_body_current_pos};
>>> +    }
>>> +    if ($$ref =~ m/\G(.+)\z/gc) {
>>> +      push @{ $self->{_body_array} }, $1;
>>> +      $self->{_body_size} += length($1);
>>> +      ++$self->{_body_current_pos};
>>> +    }
>>> +    $self->body_spool if ( $self->{_body_size} >=
>>> $self->size_threshold() );
>>> +  }
>>> +}
>>> +
>>>  sub body_size { # depreceated, use data_size() instead
>>>   my $self = shift;
>>>   $self->log(LOGWARN, "WARNING: body_size() is depreceated, use
>>> data_size() instead");
>>>
>>> ----------8<---------------------------------------
>>>
>>> On 25 December 2010 08:16, Ryszard <ryszar...@gmail.com> wrote:
>>>
>>>>
>>>> thx for your response.. :-) i'm using the same hook, but i'll be
>>>> buggered if i can work out how to rewrite the body (as opposed to just
>>>> writing to the end of it!)
>>>>
>>>> On 24 December 2010 20:58,  <qpsmtpdfrose.20.ftu...@spamgourmet.com>
>>>> wrote:
>>>>
>>>>>
>>>>> Ryszard - ryszar...@gmail.com wrote:
>>>>>
>>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I'm having a bit of trouble rewriting and entire message body with the
>>>>>> standard api calls.  what i would like to do is add header text to the
>>>>>> body of an email.
>>>>>>
>>>>>>
>>>>>
>>>>> Unfortunately, I can't remember how to do it, but it is possible. I
>>>>> used to
>>>>> do it in the hook_data_post.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>
>>
>>
>

Reply via email to