【发布时间】:2015-09-02 08:04:20
【问题描述】:
使用某些电子邮件客户端(Evolution、Thunderbird)可以正常查看电子邮件,但使用其他客户端(例如 GMX)时,邮件正文保持为空,并发送包含邮件正文的附件。
我想知道如何防止这种情况发生,因为该消息旨在供人类阅读,而将正文放在附件中很奇怪。
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";
【问题讨论】:
-
我现在使用的是 Email::Sender,一切正常。
标签: perl email attachment mime plaintext