---
name: "Courriel::Part::Multipart"
section: "3pm"
platform: "linux"
package: "libcourriel-perl"
version: "0.49-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Courriel::Part::Multipart"
---

# Courriel::Part::Multipart(3pm)

A part which contains other parts

## NAME

Courriel::Part::Multipart - A part which contains other parts

## VERSION

version 0.49

## SYNOPSIS

```
  my $headers = $part->headers;
  my $ct = $part->content_type;
  for my $subpart ( $part->parts ) { ... }
```

## DESCRIPTION

This class represents a multipart email part which contains other parts.

## API

This class provides the following methods:

### Courriel::Part::Multipart-\>new( ... )

This method creates a new part object. It accepts the following parameters:

- •

  parts

  An array reference of part objects (either Single or Multipart). This is required, but could be empty.

- •

  content\_type

  A Courriel::Header::ContentType object. This defaults to one with a mime type of "multipart/mixed".

- •

  boundary

  The part boundary. If none is provided, a unique value will be generated.

- •

  preamble

  Content that appears before the first part boundary. This will be seen by email clients that don't understand multipart messages.

- •

  epilogue

  Content that appears after the final part boundary. The spec allows for this, but it's probably not very useful.

- •

  headers

  A Courriel::Headers object containing headers for this part.

### $part-\>parts()

Returns an array (not a reference) of the parts this part contains.

### $part-\>part\_count()

Returns the number of parts this part contains.

### $part-\>boundary()

Returns the part boundary.

### $part-\>mime\_type()

Returns the mime type for this part.

### $part-\>content\_type()

Returns the Courriel::Header::ContentType object for this part.

### $part-\>headers()

Returns the Courriel::Headers object for this part.

### $part-\>is\_inline(), $part-\>is\_attachment()

These methods always return false, but exist for the sake of providing a consistent API between Single and Multipart part objects.

### $part-\>is\_multipart()

Returns true.

### $part-\>preamble()

The preamble as passed to the constructor.

### $part-\>epilogue()

The epilogue as passed to the constructor.

### $part-\>container()

Returns the Courriel or Courriel::Part::Multipart object to which this part belongs, if any. This is set when the part is added to another object.

### $part-\>stream\_to( output =\> $output )

This method will send the stringified part to the specified output. The output can be a subroutine reference, a filehandle, or an object with a `"print()"` method. The output may be sent as a single string, as a list of strings, or via multiple calls to the output.

### $part-\>as\_string()

Returns the part as a string, along with its headers. Lines will be terminated with "\\r\\n".

## ROLES

This class does the `"Courriel::Role::Part"` and `"Courriel::Role::Streams"` roles.

## SUPPORT

Bugs may be submitted at \<https://github.com/houseabsolute/Courriel/issues\>.

I am also usually active on IRC as 'autarch' on `"irc://irc.perl.org"`.

## SOURCE

The source code repository for Courriel can be found at \<https://github.com/houseabsolute/Courriel\>.

## AUTHOR

Dave Rolsky \<autarch@urth.org\>

## COPYRIGHT AND LICENSE

This software is Copyright (c) 2021 by Dave Rolsky.

This is free software, licensed under:

```
  The Artistic License 2.0 (GPL Compatible)
```

The full text of the license can be found in the *LICENSE* file included with this distribution.
