#!/bin/sh
######################################################
#
# Test encoding headers according to RFC 2047
#
######################################################

. "$MH_TEST_COMMON"

draft="$MH_TEST_DIR/mhbuild-$$.draft"
export MM_CHARSET=UTF-8

# Subject

cat >"$draft" <<!
From: Mr Foo Bar <foobar@example.com>
To: Somebody <somebody@example.com>
Subject: This is ä test

This is a test
!

runandcheck 'mhbuild "$draft"' <<!
!

runandcheck 'sed "/^Content-ID:/s/:.*/: <TESTID>/" "$draft"' <<!
From: Mr Foo Bar <foobar@example.com>
To: Somebody <somebody@example.com>
Subject: =?UTF-8?Q?This_is_=C3=A4_test?=
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <TESTID>

This is a test
!


# To + From

cat >"$draft" <<!
From: Jürgen <juergen@example.com>
To: Gönül <goenuel@example.com>
Subject: Names with Umlauts

This is a test
!

runandcheck 'mhbuild "$draft"' <<!
!

runandcheck 'sed "/^Content-ID:/s/:.*/: <TESTID>/" "$draft"' <<!
From: =?UTF-8?Q?J=C3=BCrgen?= <juergen@example.com>
To: =?UTF-8?Q?G=C3=B6n=C3=BCl?= <goenuel@example.com>
Subject: Names with Umlauts
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <TESTID>

This is a test
!
