#!/usr/bin/perl use strict; use warnings; use Email::MIME; use Mail::Sendmail; #$Mail::Sendmail::mailcfg{'from'} = 'myEmail@gmail.com'; #$Mail::Sendmail::mailcfg{'recipient'} = 'myEmail@gmail.com'; # echo "test from sendmail" | /usr/sbin/sendmail myEmail@gmail.com my %attachments = ( 'doc_name' => 'contact_test.xls', 'doc_path' => '/home/docs/', 'doc_mime_type' => 'application/vnd.ms-excel', 'doc_template_name' => 'spreadsheet'); my @parts; push @parts, Email::MIME->create( attributes => { filename => $attachments{doc_path}.$attachments{doc_name}, content_type => $attachments{doc_mime_type}, disposition => 'attachment', encoding => 'base64', name => $attachments{doc_name} } ); push @parts, Email::MIME->create( attributes => { content_type => 'text/plain', disposition => 'attachment', encoding => 'quoted-printable', charset => 'US-ASCII' }, body_str => 'this is the body' ); my $email = Email::MIME->create( header_str => [ From => 'myEmail@gmail.com', To => 'myEmail@gmail.com', Subject => 'this is my subject' ], parts => [ @parts ] ); print $email->as_string; print "end of mail as_string\n"; my $response = sendmail($email); print "Response = $response\n"; print "error1 $!\n"; print "error2 $Mail::Sendmail::error\n"; print "Log\n", $Mail::Sendmail::log;