From d7a1b5817e8389e9a4ea3d33c4dd250df9c6860c Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 14 Dec 2017 22:11:58 +0100 Subject: Issue #186: SMTPUTF8 is not an argument to RCPT + UTF8 in recipient address must switch the whole message to SMTPUTF8. --- src/vmime/net/smtp/SMTPCommand.cpp | 3 --- src/vmime/net/smtp/SMTPTransport.cpp | 22 ++++++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/vmime/net/smtp/SMTPCommand.cpp b/src/vmime/net/smtp/SMTPCommand.cpp index 04c78722..27c8ec1b 100644 --- a/src/vmime/net/smtp/SMTPCommand.cpp +++ b/src/vmime/net/smtp/SMTPCommand.cpp @@ -153,9 +153,6 @@ shared_ptr SMTPCommand::RCPT(const mailbox& mbox, const bool utf8) cmd << ">"; - if (utf8) - cmd << " SMTPUTF8"; - return createCommand(cmd.str()); } diff --git a/src/vmime/net/smtp/SMTPTransport.cpp b/src/vmime/net/smtp/SMTPTransport.cpp index fb9ea9aa..25eb72a7 100644 --- a/src/vmime/net/smtp/SMTPTransport.cpp +++ b/src/vmime/net/smtp/SMTPTransport.cpp @@ -192,15 +192,29 @@ void SMTPTransport::sendEnvelope if (needReset) commands->addCommand(SMTPCommand::RSET()); - // Emit the "MAIL" command + // Check whether we need SMTPUTF8 const bool hasSMTPUTF8 = m_connection->hasExtension("SMTPUTF8"); + bool needSMTPUTF8 = false; + + if (!sender.isEmpty()) + needSMTPUTF8 = needSMTPUTF8 || mailboxNeedsUTF8(sender); + else + needSMTPUTF8 = needSMTPUTF8 || mailboxNeedsUTF8(expeditor); + + for (size_t i = 0 ; i < recipients.getMailboxCount() ; ++i) + { + const mailbox& mbox = *recipients.getMailboxAt(i); + needSMTPUTF8 = needSMTPUTF8 || mailboxNeedsUTF8(mbox); + } + + // Emit the "MAIL" command const bool hasSize = m_connection->hasExtension("SIZE"); if (!sender.isEmpty()) { commands->addCommand( SMTPCommand::MAIL( - sender, hasSMTPUTF8 && mailboxNeedsUTF8(sender), hasSize ? size : 0 + sender, hasSMTPUTF8 && needSMTPUTF8, hasSize ? size : 0 ) ); } @@ -208,7 +222,7 @@ void SMTPTransport::sendEnvelope { commands->addCommand( SMTPCommand::MAIL( - expeditor, hasSMTPUTF8 && mailboxNeedsUTF8(expeditor), hasSize ? size : 0 + expeditor, hasSMTPUTF8 && needSMTPUTF8, hasSize ? size : 0 ) ); } @@ -220,7 +234,7 @@ void SMTPTransport::sendEnvelope for (size_t i = 0 ; i < recipients.getMailboxCount() ; ++i) { const mailbox& mbox = *recipients.getMailboxAt(i); - commands->addCommand(SMTPCommand::RCPT(mbox, hasSMTPUTF8 && mailboxNeedsUTF8(mbox))); + commands->addCommand(SMTPCommand::RCPT(mbox, hasSMTPUTF8 && needSMTPUTF8)); } // Prepare sending of message data -- cgit v1.2.3