KCodecs 5.109.0
Enumerations | Functions
KEmailAddress Namespace Reference

Enumerations

enum  EmailParseResult {
  AddressOk , AddressEmpty , UnexpectedEnd , UnbalancedParens ,
  MissingDomainPart , UnclosedAngleAddr , UnopenedAngleAddr , TooManyAts ,
  UnexpectedComma , TooFewAts , MissingLocalPart , UnbalancedQuote ,
  NoAddressSpec , DisallowedChar , InvalidDisplayName , TooFewDots
}
 Email validation result. More...
 

Functions

bool compareEmail (const QString &email1, const QString &email2, bool matchName)
 Compare two email addresses.
 
QString decodeMailtoUrl (const QUrl &mailtoUrl)
 Extracts the mailbox out of the mailto: URL.
 
QString emailParseResultToString (EmailParseResult errorCode)
 Translate the enum errorcodes from emailParseResult into i18n'd strings that can be used for msg boxes.
 
QUrl encodeMailtoUrl (const QString &mailbox)
 Creates a valid mailto: URL from the given mailbox.
 
QByteArray extractEmailAddress (const QByteArray &address)
 Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).
 
QByteArray extractEmailAddress (const QByteArray &address, QString &errorMessage)
 Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).
 
QString extractEmailAddress (const QString &address)
 This is an overloaded member function, provided for convenience.
 
QString extractEmailAddress (const QString &address, QString &errorMessage)
 Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.
 
bool extractEmailAddressAndName (const QString &aStr, QString &mail, QString &name)
 Return email address and name from string.
 
QByteArray firstEmailAddress (const QByteArray &addresses)
 Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.
 
QByteArray firstEmailAddress (const QByteArray &addresses, QString &errorMessage)
 Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.
 
QString firstEmailAddress (const QString &addresses)
 This is an overloaded member function, provided for convenience.
 
QString firstEmailAddress (const QString &addresses, QString &errorMessage)
 This is an overloaded member function, provided for convenience.
 
QString fromIdn (const QString &addrSpec)
 Decodes the punycode domain part of the given addr-spec if it's an IDN.
 
EmailParseResult isValidAddress (const QString &aStr)
 Validates an email address in the form of "Joe User" joe@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g.
 
EmailParseResult isValidAddressList (const QString &aStr, QString &badAddr)
 Validates a list of email addresses, and also allow aliases and distribution lists to be expanded before validation.
 
bool isValidSimpleAddress (const QString &aStr)
 Validates an email address in the form of joe@e.nosp@m.xamp.nosp@m.le.or.nosp@m.g.
 
QString normalizeAddressesAndDecodeIdn (const QString &addresses)
 Normalizes all email addresses in the given list and decodes all IDNs.
 
QString normalizeAddressesAndEncodeIdn (const QString &str)
 Normalizes all email addresses in the given list and encodes all IDNs in punycode.
 
QString normalizedAddress (const QString &displayName, const QString &addrSpec, const QString &comment=QString())
 Returns a normalized address built from the given parts.
 
QString quoteNameIfNecessary (const QString &str)
 Add quote characters around the given string if it contains a character that makes that necessary, in an email name, such as ",".
 
QString simpleEmailAddressErrorMsg ()
 Returns a i18n string to be used in msgboxes.
 
EmailParseResult splitAddress (const QByteArray &address, QByteArray &displayName, QByteArray &addrSpec, QByteArray &comment)
 Splits the given address into display name, email address and comment.
 
EmailParseResult splitAddress (const QString &address, QString &displayName, QString &addrSpec, QString &comment)
 This is an overloaded member function, provided for convenience.
 
QStringList splitAddressList (const QString &aStr)
 Split a comma separated list of email addresses.
 
QString toIdn (const QString &addrSpec)
 Encodes the domain part of the given addr-spec in punycode if it's an IDN.
 

Detailed Description

Since
5.5.0

Function Documentation

◆ decodeMailtoUrl()

QString KEmailAddress::decodeMailtoUrl ( const QUrl &  mailtoUrl)

Extracts the mailbox out of the mailto: URL.

Parameters
mailtoUrlthe URL with the mailto protocol, which contains the mailbox to be extracted
Returns
the mailbox, which means the display name and the address specification.

◆ encodeMailtoUrl()

QUrl KEmailAddress::encodeMailtoUrl ( const QString &  mailbox)

Creates a valid mailto: URL from the given mailbox.

Parameters
mailboxThe mailbox, which means the display name and the address specification, for example "Thomas McGuire" thoma.nosp@m.s@do.nosp@m.main..nosp@m.com. The display name is optional.
Returns
a valid mailto: URL for the given mailbox.