Created
August 7, 2013 22:10
-
-
Save battila/6179271 to your computer and use it in GitHub Desktop.
Sending html e-mail with attachment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use warnings; | |
use strict; | |
use MIME::Lite; | |
use MIME::Base64; | |
use File::Slurp; | |
use Encode; | |
my $MyAttachment = 'attachment.bin'; | |
my $to_email = '[email protected]'; | |
my $from_email = '[email protected]'; | |
my $html_msg = decode_utf8(read_file('html_email.html')) ; | |
my $msg = MIME::Lite->new ( | |
Subject => "HTML email test", | |
From => $from_email, | |
To => $to_email, | |
Type =>'multipart/mixed' | |
) or die "Error creating multipart container: $!\n"; | |
$msg->attach ( | |
Type => 'text/html', | |
Data => $html_msg | |
) or die "Error adding the html message part: $!\n"; | |
$msg->attach ( | |
Type => 'text/plain', | |
Path => $MyAttachment, | |
Filename => $MyAttachment, | |
Disposition => 'attachment' | |
) or die "Error adding $MyAttachment: $!\n"; | |
$msg->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment