diff options
Diffstat (limited to 'src/vmime/net')
-rw-r--r-- | src/vmime/net/smtp/SMTPCommand.cpp | 3 | ||||
-rw-r--r-- | src/vmime/net/smtp/SMTPTransport.cpp | 34 | ||||
-rw-r--r-- | src/vmime/net/smtp/SMTPTransport.hpp | 2 |
3 files changed, 36 insertions, 3 deletions
diff --git a/src/vmime/net/smtp/SMTPCommand.cpp b/src/vmime/net/smtp/SMTPCommand.cpp index 27c8ec1b..04c78722 100644 --- a/src/vmime/net/smtp/SMTPCommand.cpp +++ b/src/vmime/net/smtp/SMTPCommand.cpp @@ -153,6 +153,9 @@ shared_ptr <SMTPCommand> 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 2af6a195..fb9ea9aa 100644 --- a/src/vmime/net/smtp/SMTPTransport.cpp +++ b/src/vmime/net/smtp/SMTPTransport.cpp @@ -152,6 +152,22 @@ void SMTPTransport::noop() } +// static +bool SMTPTransport::mailboxNeedsUTF8(const mailbox& mb) +{ + bool all7bit = + utility::stringUtils::is7bit(mb.getEmail().getLocalName().getBuffer()) + && utility::stringUtils::is7bit(mb.getEmail().getDomainName().getBuffer()); + + for (size_t i = 0, n = mb.getName().getWordCount() ; all7bit && i != n ; ++i) + { + all7bit = utility::stringUtils::is7bit(mb.getName().getWordAt(i)->getBuffer()); + } + + return !all7bit; +} + + void SMTPTransport::sendEnvelope (const mailbox& expeditor, const mailboxList& recipients, const mailbox& sender, bool sendDATACommand, @@ -181,9 +197,21 @@ void SMTPTransport::sendEnvelope const bool hasSize = m_connection->hasExtension("SIZE"); if (!sender.isEmpty()) - commands->addCommand(SMTPCommand::MAIL(sender, hasSMTPUTF8, hasSize ? size : 0)); + { + commands->addCommand( + SMTPCommand::MAIL( + sender, hasSMTPUTF8 && mailboxNeedsUTF8(sender), hasSize ? size : 0 + ) + ); + } else - commands->addCommand(SMTPCommand::MAIL(expeditor, hasSMTPUTF8, hasSize ? size : 0)); + { + commands->addCommand( + SMTPCommand::MAIL( + expeditor, hasSMTPUTF8 && mailboxNeedsUTF8(expeditor), hasSize ? size : 0 + ) + ); + } // Now, we will need to reset next time m_needReset = true; @@ -192,7 +220,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)); + commands->addCommand(SMTPCommand::RCPT(mbox, hasSMTPUTF8 && mailboxNeedsUTF8(mbox))); } // Prepare sending of message data diff --git a/src/vmime/net/smtp/SMTPTransport.hpp b/src/vmime/net/smtp/SMTPTransport.hpp index a0f02418..7b266d3d 100644 --- a/src/vmime/net/smtp/SMTPTransport.hpp +++ b/src/vmime/net/smtp/SMTPTransport.hpp @@ -91,6 +91,8 @@ public: private: + static bool mailboxNeedsUTF8(const mailbox& mb); + /** Send the MAIL and RCPT commands to the server, checking the * response, and using pipelining if supported by the server. * Optionally, the DATA command can also be sent. |