kgish has asked for the wisdom of the Perl Monks concerning the following question:

Using MIME::Lite::TT::HTML I can send an email message with both a TEXT and HTML body, and the email client will display either the TEXT or the HTML version depending on the user preferences. This is how it is supposed to work.

However, when I add pdf attachments, while the attachments are sent just fine, BOTH the text and the HTML messages show up as visible. This is almost correct but not quite. As above, only one version should be displayed not both.

Hopefully someone can help me out. Here's an example of the code.

my $msg = MIME::Lite::TT::HTML->new( From => $mail_header->{From}, To => $mail_header->{To}, Cc => $mail_header->{Cc}, Subject => $mail_header->{Subject}, Template => { html => $self->{html_tt2}, text => $self->{txt_tt2}, }, TmplOptions => { INCLUDE_PATH => INCLUDE_PATH_EMAIL_TT2, }, TmplParams => $vars, ); $msg->attr("content-type" => "multipart/mixed"); for each attachment: $msg->attach( Type => $attachment->{Type}, Path => $filepath, Filename => $attachment->{Filename}, Disposition => 'attachment', ); end $msg->send;

Replies are listed 'Best First'.
Re: MIME::Lite::TT::HTML attachments
by Anonymous Monk on Sep 28, 2009 at 07:55 UTC
    You should not change the content-type, it is important.
      Notice that all of the other attributes are bare words. Change the quotes around content-type.

        Notice that all of the other attributes are bare words. Change the quotes around content-type.

        That doesn't matter , the error is changing the content type to the wrong value. Use the default.