The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mail::Builder::Attachment::Data - Module for handling attachments from data

SYNOPSIS

  use Mail::Builder;
  
  my $attachment = new Mail::Builder::Attachment::Data($data,'invitation.pdf','application/pdf');
  $attachment->name('party_invitation.pdf');
  print $attachment->serialize;
  
  # Append the attachment to an Mail::Builder object
  $mb->attachment($attachment); # this removes all other attachments
  OR
  $mb->attachment->add($mail);
  

DESCRIPTION

This module allows you to add attachments from data.

METHODS

Constructor

new

 my $obj = Mail::Builder::Attachment::Data->new(CONTENT,NAME,MIME);
 

Takes the data ,the file name as it should be diplayed in the e-mail message and a mime type.

Public methods

compare

 $obj->compare(OBJECT);
 or 
 $obj->compare(DATA);

Checks if two attachment objects contains the same data. Returns true or false. The compare method does not check if the mime types and name attributes of the two objects are identical.

Instead of a Mail::Builder::Attachment::Data object you can also pass a scalar value representing the data.

serialize

Returns the attachment as a MIME::Entity object.

Accessors

data

Accessor which takes/returns the data.

name

Accessor which takes/returns the name of the file as displayed in the e-mail message.

mime

Accessor which takes/returns the mime type of the file.

AUTHOR

    Maroš Kollár
    CPAN ID: MAROS
    maros [at] k-1.com
    http://www.k-1.com