From 2f9c7cd6d3652357cf6497fcac11fa1a2ec13aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Mon, 14 Jun 2021 19:13:48 +0200 Subject: [PATCH] #3219: SMTPClientSession: invalid SMTP command if empty recipients list in MailMessage --- Net/src/SMTPClientSession.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Net/src/SMTPClientSession.cpp b/Net/src/SMTPClientSession.cpp index 9703f142e..4e6cdbc94 100644 --- a/Net/src/SMTPClientSession.cpp +++ b/Net/src/SMTPClientSession.cpp @@ -419,6 +419,7 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient std::ostringstream recipient; if (pRecipients) { + if (pRecipients->empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list"); for (const auto& rec: *pRecipients) { recipient << '<' << rec << '>'; @@ -429,6 +430,7 @@ void SMTPClientSession::sendCommands(const MailMessage& message, const Recipient } else { + if (message.recipients().empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list"); for (const auto& rec: message.recipients()) { recipient << '<' << rec.getAddress() << '>'; @@ -465,6 +467,7 @@ void SMTPClientSession::sendAddresses(const std::string& from, const Recipients& std::ostringstream recipient; + if (recipients.empty()) throw Poco::InvalidArgumentException("attempting to send message with empty recipients list"); for (const auto& rec: recipients) { recipient << '<' << rec << '>';