From 45faafdced71b05271f87c0963c0d5e5b4595f4e Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 13 Dec 2009 12:50:36 +0000 Subject: [PATCH] Makes 'To' optional, like 'Cc' and 'Bcc'. An exception is still thrown if there are no recipients at all (see bug #2912670). --- src/messageBuilder.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp index a70372fb..870d59e7 100644 --- a/src/messageBuilder.cpp +++ b/src/messageBuilder.cpp @@ -54,11 +54,17 @@ ref 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);