forked from wneessen/go-mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.go
179 lines (140 loc) · 4.94 KB
/
header.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// SPDX-FileCopyrightText: 2022-2023 The go-mail Authors
//
// SPDX-License-Identifier: MIT
package mail
// Header represents a generic mail header field name
type Header string
// AddrHeader represents a address related mail Header field name
type AddrHeader string
// Importance represents a Importance/Priority value string
type Importance int
// List of common generic header field names
const (
// HeaderContentDescription is the "Content-Description" header
HeaderContentDescription Header = "Content-Description"
// HeaderContentDisposition is the "Content-Disposition" header
HeaderContentDisposition Header = "Content-Disposition"
// HeaderContentID is the "Content-ID" header
HeaderContentID Header = "Content-ID"
// HeaderContentLang is the "Content-Language" header
HeaderContentLang Header = "Content-Language"
// HeaderContentLocation is the "Content-Location" header (RFC 2110)
HeaderContentLocation Header = "Content-Location"
// HeaderContentTransferEnc is the "Content-Transfer-Encoding" header
HeaderContentTransferEnc Header = "Content-Transfer-Encoding"
// HeaderContentType is the "Content-Type" header
HeaderContentType Header = "Content-Type"
// HeaderDate represents the "Date" field
// See: https://www.rfc-editor.org/rfc/rfc822#section-5.1
HeaderDate Header = "Date"
// HeaderDispositionNotificationTo is the MDN header as described in RFC8098
// See: https://www.rfc-editor.org/rfc/rfc8098.html#section-2.1
HeaderDispositionNotificationTo Header = "Disposition-Notification-To"
// HeaderImportance represents the "Importance" field
HeaderImportance Header = "Importance"
// HeaderInReplyTo represents the "In-Reply-To" field
HeaderInReplyTo Header = "In-Reply-To"
// HeaderListUnsubscribe is the "List-Unsubscribe" header field
HeaderListUnsubscribe Header = "List-Unsubscribe"
// HeaderListUnsubscribePost is the "List-Unsubscribe-Post" header field
HeaderListUnsubscribePost Header = "List-Unsubscribe-Post"
// HeaderMessageID represents the "Message-ID" field for message identification
// See: https://www.rfc-editor.org/rfc/rfc1036#section-2.1.5
HeaderMessageID Header = "Message-ID"
// HeaderMIMEVersion represents the "MIME-Version" field as per RFC 2045
// See: https://datatracker.ietf.org/doc/html/rfc2045#section-4
HeaderMIMEVersion Header = "MIME-Version"
// HeaderOrganization is the "Organization" header field
HeaderOrganization Header = "Organization"
// HeaderPrecedence is the "Precedence" header field
HeaderPrecedence Header = "Precedence"
// HeaderPriority represents the "Priority" field
HeaderPriority Header = "Priority"
// HeaderReplyTo is the "Reply-To" header field
HeaderReplyTo Header = "Reply-To"
// HeaderSubject is the "Subject" header field
HeaderSubject Header = "Subject"
// HeaderUserAgent is the "User-Agent" header field
HeaderUserAgent Header = "User-Agent"
// HeaderXMailer is the "X-Mailer" header field
HeaderXMailer Header = "X-Mailer"
// HeaderXMSMailPriority is the "X-MSMail-Priority" header field
HeaderXMSMailPriority Header = "X-MSMail-Priority"
// HeaderXPriority is the "X-Priority" header field
HeaderXPriority Header = "X-Priority"
)
// List of common address header field names
const (
// HeaderBcc is the "Blind Carbon Copy" header field
HeaderBcc AddrHeader = "Bcc"
// HeaderCc is the "Carbon Copy" header field
HeaderCc AddrHeader = "Cc"
// HeaderEnvelopeFrom is the envelope FROM header field
// It's not included in the mail body but only used by the Client for the envelope
HeaderEnvelopeFrom AddrHeader = "EnvelopeFrom"
// HeaderFrom is the "From" header field
HeaderFrom AddrHeader = "From"
// HeaderTo is the "Receipient" header field
HeaderTo AddrHeader = "To"
)
// List of Importance values
const (
ImportanceLow Importance = iota
ImportanceNormal
ImportanceHigh
ImportanceNonUrgent
ImportanceUrgent
)
// NumString returns the importance number string based on the Importance
func (i Importance) NumString() string {
switch i {
case ImportanceNonUrgent:
return "0"
case ImportanceLow:
return "0"
case ImportanceHigh:
return "1"
case ImportanceUrgent:
return "1"
default:
return ""
}
}
// XPrioString returns the X-Priority number string based on the Importance
func (i Importance) XPrioString() string {
switch i {
case ImportanceNonUrgent:
return "5"
case ImportanceLow:
return "5"
case ImportanceHigh:
return "1"
case ImportanceUrgent:
return "1"
default:
return ""
}
}
// String returns the importance string based on the Importance
func (i Importance) String() string {
switch i {
case ImportanceNonUrgent:
return "non-urgent"
case ImportanceLow:
return "low"
case ImportanceHigh:
return "high"
case ImportanceUrgent:
return "urgent"
default:
return ""
}
}
// String returns the header string based on the given Header
func (h Header) String() string {
return string(h)
}
// String returns the address header string based on the given AddrHeader
func (a AddrHeader) String() string {
return string(a)
}