Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remaining address headers #10

Merged
merged 1 commit into from
Dec 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,21 @@ func TestParseEncodedAddressList(t *testing.T) {
if got != want {
t.Errorf("To was: %q, want: %q", got, want)
}

senderAddresses, err := e.AddressList("Sender")
if err != nil {
t.Fatal("Failed to parse Sender list:", err)
}
if len(senderAddresses) != 1 {
t.Fatalf("len(senderAddresses) == %v, want: %v", len(senderAddresses), 1)
}

// Confirm address name was decoded properly
want = "André Pirard"
got = senderAddresses[0].Name
if got != want {
t.Errorf("Sender was: %q, want: %q", got, want)
}
}

func TestDetectCharacterSetInHTML(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Example() {
fmt.Printf("Attachments: %v\n", len(env.Attachments))

// Output:
// From: James Hillyerd <jamehi03@jamehi03lx.noa.com>
// From: James Hillyerd <jamehi03@jamehi03lx.noa.com>, André Pirard <PIRARD@vm1.ulg.ac.be>
// To: Mirosław Marczak <marczak@inbucket.com>
// Subject: MIME UTF8 Test ¢ More Text
// Text Body: 1300 chars
Expand Down
19 changes: 13 additions & 6 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ var errEmptyHeaderBlock = errors.New("empty header block")
// AddressHeaders is the set of SMTP headers that contain email addresses, used by
// Envelope.AddressList(). Key characters must be all lowercase.
var AddressHeaders = map[string]bool{
"bcc": true,
"cc": true,
"delivered-to": true,
"from": true,
"reply-to": true,
"to": true,
"bcc": true,
"cc": true,
"delivered-to": true,
"from": true,
"reply-to": true,
"to": true,
"sender": true,
"resent-bcc": true,
"resent-cc": true,
"resent-from": true,
"resent-reply-to": true,
"resent-to": true,
"resent-sender": true,
}

func debug(format string, args ...interface{}) {
Expand Down
3 changes: 2 additions & 1 deletion testdata/mail/qp-utf8-header.raw
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Message-ID: <5081A889.3020108@jamehi03lx.noa.com>
Date: Fri, 19 Oct 2012 12:22:49 -0700
From: James Hillyerd <jamehi03@jamehi03lx.noa.com>
From: James Hillyerd <jamehi03@jamehi03lx.noa.com>, =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
Sender: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version: 1.0
To: =?UTF-8?Q?Miros=C5=82aw_Marczak?= <marczak@inbucket.com>
Expand Down