mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Merge pull request #57 from wneessen/getgenheader
Add GetGenHeader to Msg
This commit is contained in:
commit
10575c03e2
2 changed files with 22 additions and 0 deletions
5
msg.go
5
msg.go
|
@ -478,6 +478,11 @@ func (m *Msg) GetRecipients() ([]string, error) {
|
|||
return rl, nil
|
||||
}
|
||||
|
||||
// GetGenHeader returns the content of the requested generic header of the Msg
|
||||
func (m *Msg) GetGenHeader(h Header) []string {
|
||||
return m.genHeader[h]
|
||||
}
|
||||
|
||||
// SetBodyString sets the body of the message.
|
||||
func (m *Msg) SetBodyString(ct ContentType, b string, o ...PartOption) {
|
||||
buf := bytes.NewBufferString(b)
|
||||
|
|
17
msg_test.go
17
msg_test.go
|
@ -2105,3 +2105,20 @@ func TestMsg_WriteToFile(t *testing.T) {
|
|||
t.Errorf("output file is expected to contain data but its size is zero")
|
||||
}
|
||||
}
|
||||
|
||||
// TestMsg_GetGenHeader will test the GetGenHeader method of the Msg
|
||||
func TestMsg_GetGenHeader(t *testing.T) {
|
||||
m := NewMsg()
|
||||
m.Subject("this is a test")
|
||||
sa := m.GetGenHeader(HeaderSubject)
|
||||
if len(sa) <= 0 {
|
||||
t.Errorf("GetGenHeader on subject failed. Got empty slice")
|
||||
return
|
||||
}
|
||||
if sa[0] == "" {
|
||||
t.Errorf("GetGenHeader on subject failed. Got empty value")
|
||||
}
|
||||
if sa[0] != "this is a test" {
|
||||
t.Errorf("GetGenHeader on subject failed. Expected: %q, got: %q", "this is a test", sa[0])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue