sendmail: avoid sending mail to wrong addresses

If we get an address we cannot parse properly, we currently just strip
the unknown characters and still try to send it. This is considered
harmful as the resulting address may still be valid but different from
what the user originally intended.

Instead, skip sending to an address we cannot fully understand and
print the characters what we have scanned so far. Leading and trailing
whitespace is allowed and silently stripped.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: don't mangle e-mail headers

Leave the original To: and Cc: headers untouched, when we try to extract
addresses from them.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: support addresses inside angle brackets

When we extract addresses from the e-mail, try to first check for an
address inside angle brackets.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: support address lists

Headers To:, Cc: and Bcc: may have a list of comma-separated
addresses. Add support for that. Commas inside double quotes are ignored.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: support long header fields for recipients

Support long header fields in To:, Cc: and Bcc: headers.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: don't add To: header if it already exists

If the message we are sending already has To: header, don't add a new one.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: don't add multiple To: headers

When adding To: header, add only a single header. If there are multiple
addresses, make it multiline.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
sendmail: code shrink on top of previous patches

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Merge git://busybox.net/busybox