use MIME::Lite; $m = MIME::Lite->new; $m->build( from => 'me', to => 'you', Data => '', subject => 'Foo Bar', ); $m->attach( Type => 'text/plain', Data => 'this is an attachment' ); $m->print; __END__ Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_150137533476690" MIME-Version: 1.0 Date: Sun, 30 Jul 2017 02:42:14 +0200 From: me To: you Subject: Foo Bar X-Mailer: MIME::Lite 3.030 (F2.85; T2.09; A2.13; B3.14; Q3.13) This is a multi-part message in MIME format. --_----------=_150137533476690 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain --_----------=_150137533476690 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain this is an attachment --_----------=_150137533476690--