#!/usr/bin/perl -w use strict; use MIME::Entity; my @attach = ( q{This is to inform you}, q{that you have won}, q{a number of tribbles.} ); my @msg_body = ( q{This is to inform you}, q{that this is}, q{a test.} ); my $entity = MIME::Entity->build( Type => 'multipart/mixed', From => 'email', To => 'address', Subject => "blah", ) or die "Error creating MIME entity: $!\n"; $entity->attach( Type => 'text/plain', #Encoding => 'base64', Data => join( "\n", @msg_body ) ); $entity->attach( Filename => "report.txt", Type => 'text/plain', Data => join( "\n", @attach ) ) or die "Error adding the text message part: $!\n"; # $entity->smtpsend; $entity->print( \*STDOUT );