예제 #1
0
// GetHeader returns the undecoded value of header if found. To access the
// raw (potentially encoded) value of header, use the Message.Header.
func (m *Message) GetHeader(header string) string {
	e := textproto.MIMEHeader(m.Header).Get(header)
	if e == "" {
		return ""
	}
	dec := new(qp.WordDecoder)
	decoded, err := dec.DecodeHeader(e)
	if err != nil {
		return ""
	}
	return decoded
}
예제 #2
0
func (m *Message) GetMultipleHeaderValues(header string) (values []string) {
	headers := textproto.MIMEHeader(m.Header)
	list := headers[header]
	for _, v := range list {
		dec := new(qp.WordDecoder)
		decoded, err := dec.DecodeHeader(v)
		if err != nil {
			continue
		}
		values = append(values, decoded)
	}
	return values
}