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-05 16:27:09 +01:00
|
|
|
package mail
|
|
|
|
|
|
|
|
// TLSPolicy type describes a int alias for the different TLS policies we allow
|
|
|
|
type TLSPolicy int
|
|
|
|
|
|
|
|
const (
|
2024-02-24 21:46:48 +01:00
|
|
|
// TLSMandatory requires that the connection to the server is
|
2022-03-05 16:27:09 +01:00
|
|
|
// encrypting using STARTTLS. If the server does not support STARTTLS
|
|
|
|
// the connection will be terminated with an error
|
|
|
|
TLSMandatory TLSPolicy = iota
|
|
|
|
|
2024-02-24 21:46:48 +01:00
|
|
|
// TLSOpportunistic tries to establish an encrypted connection via the
|
2022-03-05 16:27:09 +01:00
|
|
|
// STARTTLS protocol. If the server does not support this, it will fall
|
2024-02-24 21:46:48 +01:00
|
|
|
// back to non-encrypted plaintext transmission
|
2022-03-05 16:27:09 +01:00
|
|
|
TLSOpportunistic
|
|
|
|
|
2024-02-24 21:46:48 +01:00
|
|
|
// NoTLS forces the transaction to be not encrypted
|
2022-03-05 16:27:09 +01:00
|
|
|
NoTLS
|
|
|
|
)
|
2022-03-07 16:24:49 +01:00
|
|
|
|
|
|
|
// String is a standard method to convert a TLSPolicy into a printable format
|
|
|
|
func (p TLSPolicy) String() string {
|
|
|
|
switch p {
|
|
|
|
case TLSMandatory:
|
|
|
|
return "TLSMandatory"
|
|
|
|
case TLSOpportunistic:
|
|
|
|
return "TLSOpportunistic"
|
|
|
|
case NoTLS:
|
|
|
|
return "NoTLS"
|
|
|
|
default:
|
|
|
|
return "UnknownPolicy"
|
|
|
|
}
|
|
|
|
}
|