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];