in reply to Re^6: MIME voodoo.
in thread MIME voodoo.

return $ct{'text/plain'} if exists $ct{'text/plain'}; return $ct{'text/html'} if exists $ct{'text/html'}; return $parts[0] if $which =~ /text/; return $parts[1] if $which =~ /html/;
should be
my $ct = $which eq 'html' ? 'text/html' : 'text/plain'; return $ct{$ct} if exists $ct{$ct}; # Fall back to plain text or HTML return $ct{'text/plain'} if exists $ct{'text/plain'}; return $ct{'text/html'} if exists $ct{'text/html'}; # Fall back to whatever's first return $parts[0];

By the way,

$ct{$_->content_type} = $_ for @parts;

should be changed to

$ct{$_->content_type} ||= $_ for @parts;

to get the *first* part with the right content type, not the last.

Replies are listed 'Best First'.
Re^8: MIME voodoo.
by vxp (Pilgrim) on Jul 16, 2009 at 20:54 UTC
    Now it works as I intended! Much thanks to all