Makes 'To' optional, like 'Cc' and 'Bcc'. An exception is still thrown if there are no recipients at all (see bug #2912670).

This commit is contained in:
Vincent Richard 2009-12-13 12:50:36 +00:00
parent 7a6dcdf385
commit 45faafdced

View File

@ -54,11 +54,17 @@ ref <message> messageBuilder::construct() const
if (m_from.isEmpty())
throw exceptions::no_expeditor();
if (m_to.isEmpty() || m_to.getAddressAt(0)->isEmpty())
if ((m_to.isEmpty() || m_to.getAddressAt(0)->isEmpty()) &&
(m_cc.isEmpty() || m_cc.getAddressAt(0)->isEmpty()) &&
(m_bcc.isEmpty() || m_bcc.getAddressAt(0)->isEmpty()))
{
throw exceptions::no_recipient();
}
msg->getHeader()->From()->setValue(m_from);
msg->getHeader()->To()->setValue(m_to);
if (!m_to.isEmpty())
msg->getHeader()->To()->setValue(m_to);
if (!m_cc.isEmpty())
msg->getHeader()->Cc()->setValue(m_cc);