Determine eMail's Content-Type "text/html" if message has "<" and ">" at the beginning and the end.

This commit is contained in:
Hirofumi Kosaka 2016-09-13 19:43:02 +09:00
parent 0a92781cfd
commit a85b5aed39
1 changed files with 14 additions and 2 deletions

View File

@ -1067,13 +1067,25 @@ sub pandora_execute_action ($$$$$$$$$;$) {
};
# Default content type
my $content_type = 'text/html; charset="iso-8859-1"';
my $content_type;
# Check if message looks like html.
# Assume that html message starts with "<" and ends with ">".
if ($field3 =~ /^\s*<.*>\s*$/s ) {
$content_type = 'text/html;';
}
else {
$content_type = 'text/plain;';
}
# Check if message has non-ascii chars.
# non-ascii chars should be encoded in UTF-8.
if ($field3 =~ /[^[:ascii:]]/o) {
$field3 = encode("UTF-8", $field3);
$content_type = 'text/plain; charset="UTF-8"';
$content_type .= ' charset="UTF-8"';
}
else {
$content_type .= ' charset="iso-8859-1"';
}
# Build the mail with attached content