2023-01-15 16:14:19 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022-2023 The go-mail Authors
|
2022-06-17 15:05:54 +02:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-03-09 16:52:23 +01:00
|
|
|
package mail
|
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// Charset is a type wrapper for a string representing different character encodings.
|
2022-03-13 17:15:23 +01:00
|
|
|
type Charset string
|
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// ContentType is a type wrapper for a string and represents the MIME type of the content being handled.
|
2022-03-13 17:15:23 +01:00
|
|
|
type ContentType string
|
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// Encoding is a type wrapper for a string and represents the type of encoding used for email messages
|
|
|
|
// and/or parts.
|
2022-03-09 16:52:23 +01:00
|
|
|
type Encoding string
|
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// MIMEVersion is a type wrapper for a string nad represents the MIME version used in email messages.
|
2022-03-13 17:15:23 +01:00
|
|
|
type MIMEVersion string
|
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// MIMEType is a type wrapper for a string and represents the MIME type for the Msg content or parts.
|
2022-03-13 17:15:23 +01:00
|
|
|
type MIMEType string
|
2022-03-11 10:29:44 +01:00
|
|
|
|
2022-03-09 16:52:23 +01:00
|
|
|
const (
|
|
|
|
// EncodingB64 represents the Base64 encoding as specified in RFC 2045.
|
2024-10-05 13:39:21 +02:00
|
|
|
//
|
2024-10-05 11:23:44 +02:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc2045#section-6.8
|
2022-03-09 16:52:23 +01:00
|
|
|
EncodingB64 Encoding = "base64"
|
|
|
|
|
|
|
|
// EncodingQP represents the "quoted-printable" encoding as specified in RFC 2045.
|
2024-10-05 13:39:21 +02:00
|
|
|
//
|
2024-10-05 11:23:44 +02:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc2045#section-6.7
|
2022-03-09 16:52:23 +01:00
|
|
|
EncodingQP Encoding = "quoted-printable"
|
|
|
|
|
2024-08-01 10:54:42 +02:00
|
|
|
// EncodingUSASCII represents encoding with only US-ASCII characters (aka 7Bit)
|
2024-10-05 13:39:21 +02:00
|
|
|
//
|
2024-10-05 11:23:44 +02:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc2045#section-2.7
|
2024-08-01 10:54:42 +02:00
|
|
|
EncodingUSASCII Encoding = "7bit"
|
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// NoEncoding represents 8-bit encoding for email messages as specified in RFC 6152.
|
2024-10-05 13:39:21 +02:00
|
|
|
//
|
2024-10-05 11:23:44 +02:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc2045#section-2.8
|
2024-10-05 13:39:21 +02:00
|
|
|
//
|
2024-10-05 11:23:44 +02:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc6152
|
2022-03-09 16:52:23 +01:00
|
|
|
NoEncoding Encoding = "8bit"
|
|
|
|
)
|
2022-03-11 10:29:44 +01:00
|
|
|
|
|
|
|
const (
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetUTF7 represents the "UTF-7" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetUTF7 Charset = "UTF-7"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetUTF8 represents the "UTF-8" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetUTF8 Charset = "UTF-8"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetASCII represents the "US-ASCII" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetASCII Charset = "US-ASCII"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88591 represents the "ISO-8859-1" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88591 Charset = "ISO-8859-1"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88592 represents the "ISO-8859-2" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88592 Charset = "ISO-8859-2"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88593 represents the "ISO-8859-3" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88593 Charset = "ISO-8859-3"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88594 represents the "ISO-8859-4" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88594 Charset = "ISO-8859-4"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88595 represents the "ISO-8859-5" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88595 Charset = "ISO-8859-5"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88596 represents the "ISO-8859-6" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88596 Charset = "ISO-8859-6"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88597 represents the "ISO-8859-7" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88597 Charset = "ISO-8859-7"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO88599 represents the "ISO-8859-9" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO88599 Charset = "ISO-8859-9"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO885913 represents the "ISO-8859-13" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO885913 Charset = "ISO-8859-13"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO885914 represents the "ISO-8859-14" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO885914 Charset = "ISO-8859-14"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO885915 represents the "ISO-8859-15" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO885915 Charset = "ISO-8859-15"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO885916 represents the "ISO-8859-16" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO885916 Charset = "ISO-8859-16"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO2022JP represents the "ISO-2022-JP" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO2022JP Charset = "ISO-2022-JP"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetISO2022KR represents the "ISO-2022-KR" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetISO2022KR Charset = "ISO-2022-KR"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetWindows1250 represents the "windows-1250" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetWindows1250 Charset = "windows-1250"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetWindows1251 represents the "windows-1251" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetWindows1251 Charset = "windows-1251"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetWindows1252 represents the "windows-1252" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetWindows1252 Charset = "windows-1252"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetWindows1255 represents the "windows-1255" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetWindows1255 Charset = "windows-1255"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetWindows1256 represents the "windows-1256" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetWindows1256 Charset = "windows-1256"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetKOI8R represents the "KOI8-R" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetKOI8R Charset = "KOI8-R"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetKOI8U represents the "KOI8-U" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetKOI8U Charset = "KOI8-U"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetBig5 represents the "Big5" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetBig5 Charset = "Big5"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetGB18030 represents the "GB18030" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetGB18030 Charset = "GB18030"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetGB2312 represents the "GB2312" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetGB2312 Charset = "GB2312"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetTIS620 represents the "TIS-620" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetTIS620 Charset = "TIS-620"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetEUCKR represents the "EUC-KR" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetEUCKR Charset = "EUC-KR"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetShiftJIS represents the "Shift_JIS" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetShiftJIS Charset = "Shift_JIS"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetUnknown represents the "Unknown" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetUnknown Charset = "Unknown"
|
|
|
|
|
2024-10-05 11:54:37 +02:00
|
|
|
// CharsetGBK represents the "GBK" charset.
|
2022-03-11 10:29:44 +01:00
|
|
|
CharsetGBK Charset = "GBK"
|
|
|
|
)
|
2022-03-13 10:49:07 +01:00
|
|
|
|
2024-10-05 11:23:44 +02:00
|
|
|
// MIME10 represents the MIME version "1.0" used in email messages.
|
|
|
|
const MIME10 MIMEVersion = "1.0"
|
2022-03-13 17:15:23 +01:00
|
|
|
|
|
|
|
const (
|
2024-10-05 11:23:44 +02:00
|
|
|
// TypeAppOctetStream represents the MIME type for arbitrary binary data.
|
|
|
|
TypeAppOctetStream ContentType = "application/octet-stream"
|
|
|
|
|
|
|
|
// TypeMultipartAlternative represents the MIME type for a message body that can contain multiple alternative
|
|
|
|
// formats.
|
2024-01-22 17:48:49 +01:00
|
|
|
TypeMultipartAlternative ContentType = "multipart/alternative"
|
2024-10-05 11:23:44 +02:00
|
|
|
|
|
|
|
// TypeMultipartMixed represents the MIME type for a multipart message containing different parts.
|
|
|
|
TypeMultipartMixed ContentType = "multipart/mixed"
|
|
|
|
|
|
|
|
// TypeMultipartRelated represents the MIME type for a multipart message where each part is a related file
|
|
|
|
// or resource.
|
|
|
|
TypeMultipartRelated ContentType = "multipart/related"
|
|
|
|
|
|
|
|
// TypePGPSignature represents the MIME type for PGP signed messages.
|
|
|
|
TypePGPSignature ContentType = "application/pgp-signature"
|
|
|
|
|
|
|
|
// TypePGPEncrypted represents the MIME type for PGP encrypted messages.
|
|
|
|
TypePGPEncrypted ContentType = "application/pgp-encrypted"
|
|
|
|
|
|
|
|
// TypeTextHTML represents the MIME type for HTML text content.
|
|
|
|
TypeTextHTML ContentType = "text/html"
|
|
|
|
|
|
|
|
// TypeTextPlain represents the MIME type for plain text content.
|
|
|
|
TypeTextPlain ContentType = "text/plain"
|
2022-03-13 17:15:23 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2024-10-05 11:23:44 +02:00
|
|
|
// MIMEAlternative MIMEType represents a MIME multipart/alternative type, used for emails with multiple versions.
|
2022-03-13 17:15:23 +01:00
|
|
|
MIMEAlternative MIMEType = "alternative"
|
2024-10-05 11:23:44 +02:00
|
|
|
|
|
|
|
// MIMEMixed MIMEType represents a MIME multipart/mixed type used for emails containing different types of content.
|
|
|
|
MIMEMixed MIMEType = "mixed"
|
|
|
|
|
|
|
|
// MIMERelated MIMEType represents a MIME multipart/related type, used for emails with related content entities.
|
|
|
|
MIMERelated MIMEType = "related"
|
2022-03-13 17:15:23 +01:00
|
|
|
)
|
|
|
|
|
2024-10-06 13:53:20 +02:00
|
|
|
// String satisfies the fmt.Stringer interface for the Charset type.
|
|
|
|
// It converts a Charset into a printable format.
|
|
|
|
//
|
|
|
|
// This method returns the string representation of the Charset, allowing it to be easily
|
|
|
|
// printed or logged.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// - A string representation of the Charset.
|
2022-03-13 10:49:07 +01:00
|
|
|
func (c Charset) String() string {
|
|
|
|
return string(c)
|
|
|
|
}
|
2023-10-13 15:06:54 +02:00
|
|
|
|
2024-10-06 13:53:20 +02:00
|
|
|
// String satisfies the fmt.Stringer interface for the ContentType type.
|
|
|
|
// It converts a ContentType into a printable format.
|
|
|
|
//
|
|
|
|
// This method returns the string representation of the ContentType, enabling its use
|
|
|
|
// in formatted output such as logging or displaying information to the user.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// - A string representation of the ContentType.
|
2023-10-13 15:06:54 +02:00
|
|
|
func (c ContentType) String() string {
|
|
|
|
return string(c)
|
|
|
|
}
|
|
|
|
|
2024-10-06 13:53:20 +02:00
|
|
|
// String satisfies the fmt.Stringer interface for the Encoding type.
|
|
|
|
// It converts an Encoding into a printable format.
|
|
|
|
//
|
|
|
|
// This method returns the string representation of the Encoding, which can be used
|
|
|
|
// for displaying or logging purposes.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// - A string representation of the Encoding.
|
2023-10-13 15:06:54 +02:00
|
|
|
func (e Encoding) String() string {
|
|
|
|
return string(e)
|
|
|
|
}
|