#3219: SMTPClientSession: invalid SMTP command if empty recipients list in MailMessage

This commit is contained in:
Günter Obiltschnig 2021-06-14 19:13:48 +02:00
parent 5c2cd1a4ff
commit 2f9c7cd6d3

View File

@ -419,6 +419,7 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient
std::ostringstream recipient; std::ostringstream recipient;
if (pRecipients) if (pRecipients)
{ {
if (pRecipients->empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list");
for (const auto& rec: *pRecipients) for (const auto& rec: *pRecipients)
{ {
recipient << '<' << rec << '>'; recipient << '<' << rec << '>';
@ -429,6 +430,7 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient
} }
else else
{ {
if (message.recipients().empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list");
for (const auto& rec: message.recipients()) for (const auto& rec: message.recipients())
{ {
recipient << '<' << rec.getAddress() << '>'; recipient << '<' << rec.getAddress() << '>';
@ -465,6 +467,7 @@ void SMTPClientSession::sendAddresses(const std::string& from, const Recipients&
std::ostringstream recipient; std::ostringstream recipient;
if (recipients.empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list");
for (const auto& rec: recipients) for (const auto& rec: recipients)
{ {
recipient << '<' << rec << '>'; recipient << '<' << rec << '>';