Handle more than one entitiy in From: etc.
From:, Sender: etc. may contain more than one entity in a comma separated list, i.e. a From: line like "From: Me <me@example.com>, You <you@example.com>" is perfectly valid. Handle multiple entities when splitting those headers and save all names and all adresses as (new) comma separated lists in the corresponding database fields. Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
parent
ca8ac4d50f
commit
aef5467bfe
|
@ -180,19 +180,24 @@ while (my $HeadersR = $DBQuery->fetchrow_hashref) {
|
||||||
} else {
|
} else {
|
||||||
@Address = Mail::Address->parse($Headers{$_});
|
@Address = Mail::Address->parse($Headers{$_});
|
||||||
}
|
}
|
||||||
# split each Mail::Address object
|
# split each Mail::Address object to @Names and @Adresses
|
||||||
|
my (@Names,@Adresses);
|
||||||
foreach (@Address) {
|
foreach (@Address) {
|
||||||
# take address part
|
# take address part in @Addresses
|
||||||
$Headers{$HeaderName.'_address'} = $_->address();
|
push (@Adresses, $_->address());
|
||||||
# take name part form "phrase", if there is one:
|
# take name part form "phrase", if there is one:
|
||||||
# From: My Name <addr@ess> (Comment)
|
# From: My Name <addr@ess> (Comment)
|
||||||
# otherwise, take it from "comment":
|
# otherwise, take it from "comment":
|
||||||
# From: addr@ess (Comment)
|
# From: addr@ess (Comment)
|
||||||
$Headers{$HeaderName.'_name'} = $_->comment()
|
# and push it in @Names
|
||||||
unless $Headers{$HeaderName.'_name'}= $_->phrase;
|
my ($Name);
|
||||||
$Headers{$HeaderName.'_name'} =~ s/^\((.+)\)$/$1/;
|
$Name = $_->comment() unless $Name = $_->phrase;
|
||||||
# FIMXE - handle more than one Mail::Address object!
|
$Name =~ s/^\((.+)\)$/$1/;
|
||||||
|
push (@Names, $Name);
|
||||||
}
|
}
|
||||||
|
# put all @Adresses and all @Names in %Headers as comma separated lists
|
||||||
|
$Headers{$HeaderName.'_address'} = join(', ',@Adresses);
|
||||||
|
$Headers{$HeaderName.'_name'} = join(', ',@Names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue