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-10 10:53:38 +01:00
|
|
|
package mail
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
// SMTPAuthType represents a string to any SMTP AUTH type
|
|
|
|
type SMTPAuthType string
|
|
|
|
|
|
|
|
// Supported SMTP AUTH types
|
|
|
|
const (
|
2024-02-22 15:24:19 +01:00
|
|
|
// SMTPAuthCramMD5 is the "CRAM-MD5" SASL authentication mechanism as described in RFC 4954
|
|
|
|
SMTPAuthCramMD5 SMTPAuthType = "CRAM-MD5"
|
|
|
|
|
2022-03-10 10:53:38 +01:00
|
|
|
// SMTPAuthLogin is the "LOGIN" SASL authentication mechanism
|
|
|
|
SMTPAuthLogin SMTPAuthType = "LOGIN"
|
|
|
|
|
2024-02-22 15:24:19 +01:00
|
|
|
// SMTPAuthNoAuth is equivalent to performing no authentication at all. It is a convenience
|
|
|
|
// option and should not be used. Instead, for mail servers that do no support/require
|
|
|
|
// authentication, the Client should not be used with the WithSMTPAuth option
|
|
|
|
SMTPAuthNoAuth SMTPAuthType = ""
|
|
|
|
|
2022-03-10 10:53:38 +01:00
|
|
|
// SMTPAuthPlain is the "PLAIN" authentication mechanism as described in RFC 4616
|
|
|
|
SMTPAuthPlain SMTPAuthType = "PLAIN"
|
|
|
|
|
2023-05-29 18:19:01 +02:00
|
|
|
// SMTPAuthXOAUTH2 is the "XOAUTH2" SASL authentication mechanism.
|
|
|
|
// https://developers.google.com/gmail/imap/xoauth2-protocol
|
2023-05-28 14:31:04 +02:00
|
|
|
SMTPAuthXOAUTH2 SMTPAuthType = "XOAUTH2"
|
2024-10-01 11:03:44 +02:00
|
|
|
|
2024-10-01 17:00:43 +02:00
|
|
|
// SMTPAuthSCRAMSHA1 represents the SCRAM-SHA-1 SMTP authentication mechanism
|
|
|
|
// https://datatracker.ietf.org/doc/html/rfc5802
|
|
|
|
SMTPAuthSCRAMSHA1 SMTPAuthType = "SCRAM-SHA-1"
|
|
|
|
|
|
|
|
// SMTPAuthSCRAMSHA1PLUS represents the "SCRAM-SHA-1-PLUS" authentication mechanism for SMTP.
|
|
|
|
// https://datatracker.ietf.org/doc/html/rfc5802
|
|
|
|
SMTPAuthSCRAMSHA1PLUS SMTPAuthType = "SCRAM-SHA-1-PLUS"
|
|
|
|
|
|
|
|
// SMTPAuthSCRAMSHA256 represents the SCRAM-SHA-256 authentication mechanism for SMTP.
|
|
|
|
// https://datatracker.ietf.org/doc/html/rfc7677
|
|
|
|
SMTPAuthSCRAMSHA256 SMTPAuthType = "SCRAM-SHA-256"
|
|
|
|
|
|
|
|
// SMTPAuthSCRAMSHA256PLUS represents the "SCRAM-SHA-256-PLUS" SMTP AUTH type.
|
|
|
|
// https://datatracker.ietf.org/doc/html/rfc7677
|
2024-10-01 11:03:44 +02:00
|
|
|
SMTPAuthSCRAMSHA256PLUS SMTPAuthType = "SCRAM-SHA-256-PLUS"
|
2022-03-10 10:53:38 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// SMTP Auth related static errors
|
|
|
|
var (
|
|
|
|
// ErrPlainAuthNotSupported should be used if the target server does not support the "PLAIN" schema
|
|
|
|
ErrPlainAuthNotSupported = errors.New("server does not support SMTP AUTH type: PLAIN")
|
|
|
|
|
|
|
|
// ErrLoginAuthNotSupported should be used if the target server does not support the "LOGIN" schema
|
|
|
|
ErrLoginAuthNotSupported = errors.New("server does not support SMTP AUTH type: LOGIN")
|
|
|
|
|
|
|
|
// ErrCramMD5AuthNotSupported should be used if the target server does not support the "CRAM-MD5" schema
|
|
|
|
ErrCramMD5AuthNotSupported = errors.New("server does not support SMTP AUTH type: CRAM-MD5")
|
2023-05-28 14:31:04 +02:00
|
|
|
|
|
|
|
// ErrXOauth2AuthNotSupported should be used if the target server does not support the "XOAUTH2" schema
|
|
|
|
ErrXOauth2AuthNotSupported = errors.New("server does not support SMTP AUTH type: XOAUTH2")
|
2024-10-01 11:03:44 +02:00
|
|
|
|
2024-10-01 17:00:43 +02:00
|
|
|
// ErrSCRAMSHA1AuthNotSupported should be used if the target server does not support the "SCRAM-SHA-1" schema
|
2024-10-01 11:03:44 +02:00
|
|
|
ErrSCRAMSHA1AuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-1")
|
|
|
|
|
2024-10-01 17:00:43 +02:00
|
|
|
// ErrSCRAMSHA1PLUSAuthNotSupported should be used if the target server does not support the "SCRAM-SHA-1-PLUS" schema
|
2024-10-01 11:03:44 +02:00
|
|
|
ErrSCRAMSHA1PLUSAuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-1-PLUS")
|
|
|
|
|
2024-10-01 17:00:43 +02:00
|
|
|
// ErrSCRAMSHA256AuthNotSupported should be used if the target server does not support the "SCRAM-SHA-256" schema
|
2024-10-01 11:03:44 +02:00
|
|
|
ErrSCRAMSHA256AuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-256")
|
|
|
|
|
2024-10-01 17:00:43 +02:00
|
|
|
// ErrSCRAMSHA256PLUSAuthNotSupported should be used if the target server does not support the "SCRAM-SHA-256-PLUS" schema
|
2024-10-01 11:03:44 +02:00
|
|
|
ErrSCRAMSHA256PLUSAuthNotSupported = errors.New("server does not support SMTP AUTH type: SCRAM-SHA-256-PLUS")
|
2022-03-10 10:53:38 +01:00
|
|
|
)
|