-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include content type in empty MIME parts
Changes the MIME generation code to always include the "Content-Type" header in each of the the MIME parts, even if the part is empty. Previously an empty plain text or HTML body could cause some SMTP servers to reject the mail due to the missing headers. Emails that included both HTML and plain-text conent were not affected. Fixes #61.
- Loading branch information
Showing
4 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,18 @@ func TestIntegration_TLS(t *testing.T) { | |
}, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "empty", | ||
fn: func(m *MailYak) { | ||
m.From("[email protected]") | ||
m.FromName("From Example") | ||
m.To("[email protected]") | ||
m.Bcc("[email protected]", "[email protected]") | ||
m.Subject("TLS empty") | ||
m.ReplyTo("[email protected]") | ||
}, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "authenticated", | ||
auth: smtp.PlainAuth("ident", "user", "pass", "127.0.0.1"), | ||
|
@@ -90,7 +102,7 @@ func TestIntegration_TLS(t *testing.T) { | |
m.To("[email protected]") | ||
m.Subject("TLS Attachment test") | ||
m.ReplyTo("[email protected]") | ||
m.HTML().Set("Attachment MF5: " + hashString) | ||
m.HTML().Set("Attachment MD5: " + hashString) | ||
m.Attach("test.bin", bytes.NewReader(data)) | ||
}, | ||
wantErr: nil, | ||
|
@@ -152,6 +164,18 @@ func TestIntegration_PlainText(t *testing.T) { | |
}, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "empty", | ||
fn: func(m *MailYak) { | ||
m.From("[email protected]") | ||
m.FromName("From Example") | ||
m.To("[email protected]") | ||
m.Bcc("[email protected]", "[email protected]") | ||
m.Subject("Plaintext empty") | ||
m.ReplyTo("[email protected]") | ||
}, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "authenticated", | ||
auth: smtp.PlainAuth("ident", "user", "pass", "127.0.0.1"), | ||
|
@@ -183,7 +207,7 @@ func TestIntegration_PlainText(t *testing.T) { | |
m.To("[email protected]") | ||
m.Subject("PLAIN - Attachment test") | ||
m.ReplyTo("[email protected]") | ||
m.HTML().Set("Attachment MF5: " + hashString) | ||
m.HTML().Set("Attachment MD5: " + hashString) | ||
m.Attach("test.bin", bytes.NewReader(data)) | ||
}, | ||
wantErr: nil, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters