Search notes:

Perl module MIME::Lite

#
#   This script sends a mail with an attachment.
#   Mutliple attachments can be sent by repeatedly
#   calling $msg -> attach()
#
#   NOTE that MIME::Lite is not recommended by
#   its current maintainer (7.7.2014).
#
use warnings;
use strict;

use MIME::Lite;

my $sender_mail_address    = shift;
my $smtp_server            = shift;
my $recipient_mail_address = shift;
my $subject                = shift;
my $filename               = shift;
my $auth_passwd            = shift;

MIME::Lite->send('smtp', $smtp_server, Timeout=>60, AuthUser => $sender_mail_address, AuthPass => $auth_passwd);

my $msg = MIME::Lite->new(
    From    => $sender_mail_address,
    To      => $recipient_mail_address,
    Subject => $subject,
    Data    =>"Attached is a file.",
    Type    =>"multipart/mixed",
);

$msg->attach('Type'     => 'application/octet-stream',
             'Encoding' => 'base64',
              Path      => $filename
          );

$msg->send();

Github repository PerlModules, path: /MIME/Lite/script.pl

See also

Perl modules
Perl module MIME::Base64, Perl module Email::MIME
MIME

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1741108836, '3.147.60.29', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/MIME/Lite/index(80): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78