The email can be viewed normally using some email clients (Evolution, Thunderbird), but with other clients (e.g., GMX) the body of the message remains empty and an attachment containing the body of the message is sent.
I would like to know how I can prevent this from happening, since the message is intended to be read by humans and having the body in an attachment is weird.
my $ServerName = "";
my $from_address = '';
my $to_address = '';
my $subject = 'MIME Test: Text';
my $mime_type = 'text';
my $message_body = "This is a test.\n";
# Create the initial text of the message
my $mime_msg = MIME::Lite->new(
From => $from_address,
To => $to_address,
Subject => $subject,
Type => $mime_type,
Data => encode("utf8",$message_body)
) or die "Error creating MIME body: $!\n";
# encode body of message as a string so that we can pass it to Net::SMTP.
$message_body = $mime_msg->body_as_string();
# Let MIME::Lite handle the Net::SMTP details
MIME::Lite->send( 'smtp', $ServerName,);# AuthUser => $user, AuthPass => $pass );
$mime_msg->send() or die "Error sending message: $!\n";
I think this is the closes thing you're going to get to an answer
The documentation for
MIME::Lite
says thisThe "current maintainer" is the inimitable Ricardo Signes and I suggest you follow his advice