Blnukem Blnukem - 1 year ago 66
Perl Question

Error with Email::MIME::CreateHTML

I trying to figure out this error with no luck I'm using the cpan Email::MIME::CreateHTML modal any assistance is greatly appreciated.


syntax error at Email/MIME/ line 203, near "croak "You must supply a body""



print "Content-type: text/html\n\n";

use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

use Email::Sender::Transport::SMTPS;
use Email::MIME::CreateHTML;

my $SendTo = '';
my $SendFrom = '';
my $Subject = 'test MSG';

my $SMTP_Server = '';
my $SMTP_SSL = 'starttls';
my $SMTP_Port = 587;
my $SMTP_User = '';
my $SMTP_Password = 'MyGmailPassword';

my $eMailMessage = "Test MSG";

use Email::Sender::Transport::SMTPS;
use Email::MIME::CreateHTML;

my $transport = Email::Sender::Transport::SMTPS->new({
host => $SMTP_Server,
ssl => $SMTP_SSL,
port => $SMTP_Port,
sasl_username => $SMTP_User,
sasl_password => $SMTP_Password,
debug => 1,

my $email = Email::MIME->create_html(
header => [
To => $SendTo,
From => $SendFrom,
Subject => $Subject,

body => $eMailMessage


sendmail($email, { transport => $transport });

print 'Mail Sent';

Answer Source

You must have an old version of Email::MIME::CreateHTML. This looks like a bug that was fixed in version 1.030:

This happens because the create_html method being mixed into Email::MIME does not have croak in scope. The fix is to simply explicitly load Carp again after the package Email::MIME declaration.

I'm not sure exactly how this ever worked, honestly.

Upgrade to the latest version.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download