=encoding utf8

=head1 NAME

Mail::Message::Head::ResentGroup - header fields tracking message delivery

=head1 INHERITANCE

 Mail::Message::Head::ResentGroup
   is a Mail::Message::Head::FieldGroup
   is a Mail::Reporter

=head1 SYNOPSIS

  use Mail::Message::Head::ResentGroup;
  my $rg = Mail::Message::Head::ResentGroup->new(head => $head,
               From => 'me@home.nl', To => 'You@tux.aq');
  $head->addResentGroup($rg);

  my $rg = $head->addResentGroup(From => 'me');

  my @from = $rg->From;

  my @rgs = $head->resentGroups;
  $rg[2]->delete if @rgs > 2;

=head1 DESCRIPTION

A I<resent group> is a set of header fields which describe one intermediate
step in the message transport.  Resent groups B<have NOTHING to do> with
user activety; there is no relation to the C<user's> sense of creating
reply, forward, or bounce messages at all!

Extends L<"DESCRIPTION" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"DESCRIPTION">.

=head1 METHODS

Extends L<"METHODS" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"METHODS">.

=head2 Constructors

Extends L<"Constructors" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"Constructors">.

=over 4

=item $obj-E<gt>B<clone>()

Inherited, see L<Mail::Message::Head::FieldGroup/"Constructors">

=item $obj-E<gt>B<from>( [<$head|$message>, %options] )

WARNING: this method has two very different purposes.  For backward
compatibility reasons, without arguments L<resentFrom()|Mail::Message::Head::ResentGroup/"Access to the header"> is called to
return the C<From> field of this resent group.

With any arguments, a list of C<Mail::Message::Head::ResentGroup> objects
is returned, taken from the specified C<$message> or message C<$head>.
Improves base, see L<Mail::Message::Head::FieldGroup/"Constructors">

=item $any-E<gt>B<implementedTypes>()

Inherited, see L<Mail::Message::Head::FieldGroup/"Constructors">

=item $class-E<gt>B<new>( [@fields], %options )

Create an object which maintains one set of resent headers.  The
C<@fields> are L<Mail::Message::Field|Mail::Message::Field> objects from the same header.

All C<%options> which start with capitals will be used to construct additional
fields.  These option names are prepended with C<Resent-*>, keeping the
capitization of what is specified.
Improves base, see L<Mail::Message::Head::FieldGroup/"Constructors">

 -Option      --Defined in                     --Default
  Bcc                                            undef
  Cc                                             undef
  Date                                           <now>
  Delivered-To                                   undef
  From                                           <required>
  Message-ID                                     <uniquely created>
  Received                                       <created>
  Return-Path                                    undef
  Sender                                         undef
  To                                             undef
  head                                           <created automatically>
  message_head                                   undef
  software      Mail::Message::Head::FieldGroup  undef
  type          Mail::Message::Head::FieldGroup  undef
  version       Mail::Message::Head::FieldGroup  undef

=over 2

=item Bcc => $text|$field|\@fields

=item Cc => $text|$field|\@fields

=item Date => $date

When this resent-group is dispatched by the resender of the message. Like
the C<Date> field, it is not the date and time that the message was
actually transported.

=item Delivered-To => $text|$field

=item From => $text|$field|\@fields

=item Message-ID => $text|$field

The C<Resent-Message-ID> which identifies this resent group.  The C<$field>
must contain a message id.

=item Received => $text

The C<Received> field is the starting line for a resent group of header
lines. If it is not defined, one is created using L<createReceived()|Mail::Message::Head::ResentGroup/"Internals">.

=item Return-Path => $text|$field

=item Sender => $text|$field

Only permitted when more than one from address is specified.  In this case,
it selects one of these addresses as the main originator of the message.

=item To => $text|$field|\@fields

=item head => $head

The C<$head> object where the data is stored in. By default a
L<Mail::Message::Head::Partial|Mail::Message::Head::Partial> is created for you.

=item message_head => $head

The real C<$head> of the message where this resent group is part of.  The
C<head> used in this class is only a container for a subset of fields.

=item software => STRING

=item type => STRING

=item version => STRING

=back

=back

=head2 Attributes

Extends L<"Attributes" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"Attributes">.

=head2 The header

Extends L<"The header" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"The header">.

=over 4

=item $obj-E<gt>B<add>( <$field, $value> | $object )

All fields appear only once, so C<add()> behaves as L<set()|Mail::Message::Head::ResentGroup/"The header">.
Improves base, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<addFields>( [$fieldnames] )

Not applicable to resent-groups: the same name can appear in more than
one group.  Therefore, a FIELDNAME is sufficiently distinctive.
Improves base, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<attach>($head)

Inherited, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<delete>()

Inherited, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<fieldNames>()

Inherited, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<fields>()

Inherited, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<head>()

Inherited, see L<Mail::Message::Head::FieldGroup/"The header">

=item $obj-E<gt>B<messageHead>( [$head] )

Returns (optionally after setting) the real header where this resent group
belongs to.  This may be C<undef> at creation, and then later filled in
when L<Mail::Message::Head::Complete::addResentGroup()|Mail::Message::Head::Complete/"Access to the header"> is called.

=item $obj-E<gt>B<orderedFields>()

Returns the fields in the order as should appear in header according
to rfc2822.  For the C<Resent-*> fields of the group, the order is
not that important, but the C<Return-Path>, C<Delivered-To>, and C<Received>
must come first.  Only fields mentioned in the RFC are returned.

=item $obj-E<gt>B<set>( <$field, $value> | $object )

Set a C<$field> to a (new) C<$value>.  The C<$field> names which do not start with
'Resent-*' but need it will have that added.  It is also an option to
specify a fully prepared message field C<$object>.  In any case, a field
C<$object> is returned.

» example: 

  my $rg = Mail::Message::Head::ResentGroup->new;
  $rg->set(To => 'fish@tux.aq');
  $msg->addResentGroup($rg);
  $msg->send;

  $msg->bounce(To => 'fish@tux.aq')->send;   # the same
  my $rg = Mail::Message::Head::ResentGroup->new(To => 'fish@tux.aq');

=back

=head2 Access to the header

Extends L<"Access to the header" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"Access to the header">.

=over 4

=item $obj-E<gt>B<bcc>()

In scalar context, the C<Resent-Bcc> field is returned.  In list context,
the addresses as specified within the bcc field are returned as
L<Mail::Address|Mail::Address> objects.  Bcc fields are not transmitted (hidden for
external parties).

=item $obj-E<gt>B<cc>()

In scalar context, the C<Resent-Cc> field is returned.  In list context,
the addresses as specified within the cc field are returned as
L<Mail::Address|Mail::Address> objects.

=item $obj-E<gt>B<date>()

Returns the C<Resent-Date> field, or C<undef> if it was not defined.

=item $obj-E<gt>B<dateTimestamp>()

The timestamp as stored within the C<Resent-Date> field converted to
local system time.

=item $obj-E<gt>B<deliveredTo>()

The field which describes the C<Delivered-To> of this resent group.

=item $obj-E<gt>B<destinations>()

Returns a list of all addresses specified in the C<Resent-To>, C<-Cc>, and
C<-Bcc> fields of this resent group.

=item $any-E<gt>B<isResentGroupFieldName>($name)

Z<>

=item $obj-E<gt>B<messageId>()

Returns the message-ID used for this group of resent lines.

=item $obj-E<gt>B<received>()

The field which describes the C<Received> data of this resent group.

=item $obj-E<gt>B<receivedTimestamp>()

The timestamp as stored within the C<Received> field converted to
local system time.

=item $obj-E<gt>B<resentFrom>()

In scalar context, the C<Resent-From> field is returned.  In list
context, the addresses as specified within the from field are
returned as L<Mail::Address|Mail::Address> objects.

For reasons of backward compatibility and consistency, the L<from()|Mail::Message::Head::ResentGroup/"METHODS">
method will return the same as this method.

=item $obj-E<gt>B<returnPath>()

The field which describes the C<Return-Path> of this resent group.

=item $obj-E<gt>B<sender>()

In scalar context, the C<Resent-Sender> field is returned.  In list
context, the addresses as specified within the from field are
returned as L<Mail::Address|Mail::Address> objects.

=item $obj-E<gt>B<software>()

Inherited, see L<Mail::Message::Head::FieldGroup/"Access to the header">

=item $obj-E<gt>B<to>()

In scalar context, the C<Resent-To> field is returned.  In list context,
the addresses as specified within the to field are returned as
L<Mail::Address|Mail::Address> objects.

=item $obj-E<gt>B<type>()

Inherited, see L<Mail::Message::Head::FieldGroup/"Access to the header">

=item $obj-E<gt>B<version>()

Inherited, see L<Mail::Message::Head::FieldGroup/"Access to the header">

=back

=head2 Internals

Extends L<"Internals" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"Internals">.

=over 4

=item $obj-E<gt>B<collectFields>( [$name] )

Inherited, see L<Mail::Message::Head::FieldGroup/"Internals">

=item $obj-E<gt>B<createReceived>( [$domain] )

Create a received field for this resent group.  This is automatically
called if none was specified during creation of this resent group object.

The content of this field is described in RFC2821 section 4.4.  It could use
some improvement.

=item $obj-E<gt>B<detected>($type, $software, $version)

Inherited, see L<Mail::Message::Head::FieldGroup/"Internals">

=back

=head2 Error handling

Extends L<"Error handling" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"Error handling">.

=over 4

=item $obj-E<gt>B<AUTOLOAD>()

Inherited, see L<Mail::Reporter/"Error handling">

=item $obj-E<gt>B<details>()

Inherited, see L<Mail::Message::Head::FieldGroup/"Error handling">

=item $obj-E<gt>B<notImplemented>()

Inherited, see L<Mail::Reporter/"Error handling">

=item $obj-E<gt>B<print>( [$fh] )

Inherited, see L<Mail::Message::Head::FieldGroup/"Error handling">

=back

=head2 Cleanup

Extends L<"Cleanup" in Mail::Message::Head::FieldGroup|Mail::Message::Head::FieldGroup/"Cleanup">.

=over 4

=item $obj-E<gt>B<DESTROY>()

Inherited, see L<Mail::Reporter/"Cleanup">

=back

=head1 DIAGNOSTICS

=over 4

=item Error: class $package does not implement method $method.

Fatal error: the specific C<$package> (or one of its superclasses) does not
implement this method where it should. This message means that some other
related classes do implement this method however the class at hand does
not.  Probably you should investigate this and probably inform the author
of the package.
Cast by C<notImplemented()>

=back

=head1 SEE ALSO

This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F<http://perl.overmeer.net/mailbox/>

=head1 LICENSE

For contributors see file ChangeLog.

This software is copyright (c) 2001-2026 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

