Botan 3.13.0
Crypto and TLS for C&
Botan::SmtpUtf8Mailbox Class Referencefinal

#include <email.h>

Public Member Functions

const DNSNamedomain () const
 The domain, as an LDH host name in A-label form (RFC 9598 Section 3).
const std::string & local_part () const
 The local-part, UTF-8 encoded, should contain non-ASCII.
auto operator<=> (const SmtpUtf8Mailbox &) const =default
bool operator== (const SmtpUtf8Mailbox &) const =default
std::string to_string () const

Static Public Member Functions

static std::optional< SmtpUtf8Mailbox > from_string (std::string_view addr)

Detailed Description

A parsed internationalized mailbox (SmtpUTF8Mailbox) as defined by RFC 9598.

The mailbox is local-part "@" domain, where local-part is a UTF-8 string. The RFC specifically requires that this name only be used when the local-part of the name is not representable in ASCII.

Prior specifications of this name (RFC 8398) allowed for any internationalized domains be stored as U-label names. However RFC 9598 changes this so that only A-label names are allowed. This restriction is enforced by this type.

Definition at line 86 of file email.h.

Member Function Documentation

◆ domain()

const DNSName & Botan::SmtpUtf8Mailbox::domain ( ) const
inline

The domain, as an LDH host name in A-label form (RFC 9598 Section 3).

Definition at line 99 of file email.h.

99{ return m_domain; }

Referenced by Botan::GeneralName::matches_email(), and operator==().

◆ from_string()

std::optional< SmtpUtf8Mailbox > Botan::SmtpUtf8Mailbox::from_string ( std::string_view addr)
static

Parse an SmtpUTF8Mailbox

Parameters
addrthe address to parse
Returns
the parsed address, or nullopt if addr is not a valid SmtpUTF8Mailbox

Definition at line 99 of file email.cpp.

99 {
100 auto parsed = parse_email_address(addr);
101
102 if(parsed) {
103 /*
104 * RFC 9598 Section 3
105 * SmtpUTF8Mailbox subjectAltName MUST NOT be used unless the Local-part
106 * of the email address contains non-ASCII characters. When the Local-
107 * part is ASCII, rfc822Name subjectAltName MUST be used instead of
108 * SmtpUTF8Mailbox.
109 *
110 * We do not currently enforce this on the decoding side.
111 */
112 return SmtpUtf8Mailbox(std::move(parsed->first), std::move(parsed->second));
113 }
114
115 return {};
116}

Referenced by Botan::AlternativeName::decode_from().

◆ local_part()

const std::string & Botan::SmtpUtf8Mailbox::local_part ( ) const
inline

The local-part, UTF-8 encoded, should contain non-ASCII.

Definition at line 96 of file email.h.

96{ return m_local_part; }

Referenced by operator==().

◆ operator<=>()

auto Botan::SmtpUtf8Mailbox::operator<=> ( const SmtpUtf8Mailbox & ) const
default

Order two mailboxes

Returns
the ordering of this mailbox relative to the other

◆ operator==()

bool Botan::SmtpUtf8Mailbox::operator== ( const SmtpUtf8Mailbox & ) const
default

Compare two mailboxes

Returns
true if the two mailboxes are equal

References domain(), and local_part().

◆ to_string()

std::string Botan::SmtpUtf8Mailbox::to_string ( ) const

Format the mailbox as "local-part@domain"

Returns
the text form of the mailbox

Definition at line 94 of file email.cpp.

94 {
95 return fmt("{}@{}", m_local_part, m_domain.to_string());
96}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::fmt().


The documentation for this class was generated from the following files: