Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Perl/CGI - Sending email with other file content

Jul 19, 2012 6:14AM PDT

I've been working on a script and now I need to add a part where it sends the email and uses the contents of a file I open as the message part. Here's what I'm trying now (and I've tried many other things)

#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use MIME::Lite;

print header;

open FILE, "<", "newsletter.html" or die $!;
my @newsletter = <FILE>;


my $email = 'robert@businessinnovationsmo.com';
my $msg = MIME::Lite->new
(
Subject => "Newsletter",
From => 'noreply@nonprofitinsight.com',
To => $email,
Type => 'text/html',
Data => @newsletter
);
$msg->send();


print @newsletter;

close FILE;


It will display the page great, but the email is blank. Any suggestions would help a ton, thanks!

Discussion is locked