#!/usr/bin/env perl use 5.010; use strict; use warnings; use utf8::all; #use Mail::Send; use MIME::Entity; use Encode; use POSIX qw(locale_h); setlocale(LC_CTYPE, "en_GB.UTF-8"); setlocale(LC_COLLATE, "en_GB.UTF-8"); my @testers = qw(andy@strugglers.net); send_emails(@testers); exit 0; sub create_email { my ($args) = @_; # MIME encode headers according to RFC 2047, fixes issue #108 my $to = encode('MIME-Q', $args->{to}); my $subj = encode('MIME-Q', $args->{subject}); my $top = MIME::Entity->build( Type => 'text/plain', Charset => 'utf8', Encoding => 'quoted-printable', From => 'BitFolk test Email ', To => $to, Subject => $subj, 'X-Mailer' => 'BitFolk Test Script', Organization => 'BITFOLK LIMITED, Registered in England ' . '(No. 6032951, VAT no. 990 4159 02); 21 ' . 'Trevithick Close, Feltham, Greater London, ' . 'TW14 9XJ, United Kingdom; ' . 'https://bitfolk.com/contact.html', Data => Encode::encode_utf8($args->{data}), ); return $top; } sub send_emails { my @contacts = @_; my $subject = 'BitFolk test email (Without multipart/mixed container)'; my $nicetext = < $contact, subject => $subject, data => $nicetext, } ); $top->attach( Path => '/srv/bitfolk/invoices/templates/vat_invoice.pdf', Type => 'application/pdf', Encoding => 'base64', Description => 'Invoice template', ); open my $mfh, '| /usr/sbin/sendmail -t -oi -oem -f billing@bitfolk.com' or die "open: $!"; $top->print($mfh); close $mfh; # |Print a copy to STDOUT for debugging. $top->print(\*STDOUT); } }