Check for DSN extension support before using it.
This commit is contained in:
parent
9205c9d0ab
commit
6c4bd0dda9
@ -58,6 +58,12 @@ string dsnAttributes::getEnvelopId() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool dsnAttributes::isEmpty() const {
|
||||||
|
|
||||||
|
return m_notifications.empty() && m_returnFormat.empty() && m_envelopId.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // net
|
} // net
|
||||||
} // vmime
|
} // vmime
|
||||||
|
|
||||||
|
@ -90,6 +90,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
string getEnvelopId() const;
|
string getEnvelopId() const;
|
||||||
|
|
||||||
|
/** Returns whether the object is empty, and no attribute has been set.
|
||||||
|
*
|
||||||
|
* @return true if object is empty, or false otherwise
|
||||||
|
*/
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
string m_notifications;
|
string m_notifications;
|
||||||
|
@ -151,6 +151,59 @@ const char* SMTPMessageSizeExceedsCurLimitsException::name() const throw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// SMTPExtensionNotSupportedException
|
||||||
|
//
|
||||||
|
|
||||||
|
SMTPExtensionNotSupportedException::SMTPExtensionNotSupportedException(const string &what, const exception& other)
|
||||||
|
: net_exception(what.empty() ? "A required extension is not supported by the SMTP server." : what, other) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SMTPExtensionNotSupportedException::~SMTPExtensionNotSupportedException() throw() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
exception* SMTPExtensionNotSupportedException::clone() const {
|
||||||
|
|
||||||
|
return new SMTPExtensionNotSupportedException(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* SMTPExtensionNotSupportedException::name() const throw() {
|
||||||
|
|
||||||
|
return "SMTPExtensionNotSupportedException";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// SMTPDSNExtensionNotSupportedException
|
||||||
|
//
|
||||||
|
|
||||||
|
SMTPDSNExtensionNotSupportedException::SMTPDSNExtensionNotSupportedException(const exception& other)
|
||||||
|
: SMTPExtensionNotSupportedException("RFC-1891 DSN extension is not supported by the SMTP server.", other) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SMTPDSNExtensionNotSupportedException::~SMTPDSNExtensionNotSupportedException() throw() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
exception* SMTPDSNExtensionNotSupportedException::clone() const {
|
||||||
|
return new SMTPDSNExtensionNotSupportedException(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* SMTPDSNExtensionNotSupportedException::name() const throw() {
|
||||||
|
|
||||||
|
return "SMTPDSNExtensionNotSupportedException";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // smtp
|
} // smtp
|
||||||
} // net
|
} // net
|
||||||
} // vmime
|
} // vmime
|
||||||
|
@ -120,6 +120,34 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** SMTP error: a required extension is not supported by the server.
|
||||||
|
*/
|
||||||
|
class VMIME_EXPORT SMTPExtensionNotSupportedException : public exceptions::net_exception {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SMTPExtensionNotSupportedException(const string& what, const exception& other = NO_EXCEPTION);
|
||||||
|
~SMTPExtensionNotSupportedException() throw();
|
||||||
|
|
||||||
|
exception* clone() const;
|
||||||
|
const char* name() const throw();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** SMTP error: RFC-1891 DSN extension is not supported by the server.
|
||||||
|
*/
|
||||||
|
class VMIME_EXPORT SMTPDSNExtensionNotSupportedException : public SMTPExtensionNotSupportedException {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SMTPDSNExtensionNotSupportedException(const exception& other = NO_EXCEPTION);
|
||||||
|
~SMTPDSNExtensionNotSupportedException() throw();
|
||||||
|
|
||||||
|
exception* clone() const;
|
||||||
|
const char* name() const throw();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // smtp
|
} // smtp
|
||||||
} // net
|
} // net
|
||||||
} // vmime
|
} // vmime
|
||||||
|
@ -186,6 +186,7 @@ void SMTPTransport::sendEnvelope(
|
|||||||
const size_t size,
|
const size_t size,
|
||||||
const dsnAttributes& dsnAttrs
|
const dsnAttributes& dsnAttrs
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// If no recipient/expeditor was found, throw an exception
|
// If no recipient/expeditor was found, throw an exception
|
||||||
if (recipients.isEmpty()) {
|
if (recipients.isEmpty()) {
|
||||||
throw exceptions::no_recipient();
|
throw exceptions::no_recipient();
|
||||||
@ -193,6 +194,11 @@ void SMTPTransport::sendEnvelope(
|
|||||||
throw exceptions::no_expeditor();
|
throw exceptions::no_expeditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If DSN extension is used, ensure it is supported by the server
|
||||||
|
if (!dsnAttrs.isEmpty() && !m_connection->hasExtension("DSN")) {
|
||||||
|
throw SMTPDSNExtensionNotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const bool needReset = m_needReset;
|
const bool needReset = m_needReset;
|
||||||
const bool hasPipelining = m_connection->hasExtension("PIPELINING") &&
|
const bool hasPipelining = m_connection->hasExtension("PIPELINING") &&
|
||||||
|
Loading…
Reference in New Issue
Block a user