ToString returns a string representation of the message.
()
| 77 | |
| 78 | // ToString returns a string representation of the message. |
| 79 | func (m Message) ToString() string { |
| 80 | var buf bytes.Buffer |
| 81 | |
| 82 | fmt.Fprintf(&buf, "Subject: %v\n", m.Subject) |
| 83 | |
| 84 | headers := slices.AppendSeq(make([]string, 0, len(m.Headers)), maps.Keys(m.Headers)) |
| 85 | |
| 86 | sort.Strings(headers) |
| 87 | |
| 88 | for _, k := range headers { |
| 89 | fmt.Fprintf(&buf, "%v: %v\n", k, m.Headers[k]) |
| 90 | } |
| 91 | |
| 92 | fmt.Fprintf(&buf, "\n%v", m.Body) |
| 93 | |
| 94 | return buf.String() |
| 95 | } |
| 96 | |
| 97 | // Supported message formats. |
| 98 | const ( |