【问题标题】:Plain text emails displayed as attachment on some email clients在某些电子邮件客户端上显示为附件的纯文本电子邮件
【发布时间】: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


【解决方案1】:

我认为这是你要得到答案的最接近的事情

documentation for MIME::Lite 这么说

MIME::Lite 不被当前的维护者推荐。有许多替代方案,例如 Email::MIME 或 MIME::Entity 和 Email::Sender,您可能应该使用它们。 MIME::Lite 继续产生奇怪的错误报告,并且由于有更好的替代方案,它没有收到大量的重构。请考虑使用其他东西。

“当前的维护者”是无与伦比的 Ricardo Signes,我建议你听从他的建议

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-31
    • 1970-01-01
    • 1970-01-01
    • 2013-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多