#!/usr/bin/perl -w use strict; use warnings; use MIME::Lite; use Data::Dumper; my $msg = MIME::Lite->new(); dumpObject($msg); $msg->build(to => 'user1 ', from => 'user2 '); $msg->build(subject => 'a message subject'); dumpObject($msg); $msg->attach( Type => 'text/plain', Data => 'This is the body text of the email', ); dumpObject($msg); $msg->send; # <------ 'no data' error here sub dumpObject { my ($object) = @_; my $output = Data::Dumper->Dump([$object], ['foo']); $output =~ s/\$foo = //; print $output; }