diff options
author | Vincent Richard <[email protected]> | 2013-06-12 19:19:36 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2013-06-12 19:19:36 +0000 |
commit | 93c8d3a0717de4b82e765f6df349e48819be0770 (patch) | |
tree | 32c643c35b3e45d340d30d06e92c476d41039644 /src | |
parent | Homogeneous use of vmime::string. (diff) | |
download | vmime-93c8d3a0717de4b82e765f6df349e48819be0770.tar.gz vmime-93c8d3a0717de4b82e765f6df349e48819be0770.zip |
Added support for SMTPUTF8 extension (RFC-6531).
Diffstat (limited to 'src')
-rw-r--r-- | src/emailAddress.cpp | 11 | ||||
-rw-r--r-- | src/net/smtp/SMTPCommand.cpp | 29 | ||||
-rw-r--r-- | src/net/smtp/SMTPTransport.cpp | 9 |
3 files changed, 40 insertions, 9 deletions
diff --git a/src/emailAddress.cpp b/src/emailAddress.cpp index 7136a5b4..c4119aba 100644 --- a/src/emailAddress.cpp +++ b/src/emailAddress.cpp @@ -525,4 +525,15 @@ const string emailAddress::toString() const } +const text emailAddress::toText() const +{ + text txt; + txt.appendWord(vmime::create <vmime::word>(m_localName)); + txt.appendWord(vmime::create <vmime::word>("@", vmime::charsets::US_ASCII)); + txt.appendWord(vmime::create <vmime::word>(m_domainName)); + + return txt; +} + + } // vmime diff --git a/src/net/smtp/SMTPCommand.cpp b/src/net/smtp/SMTPCommand.cpp index 35ea56fb..d9f5c286 100644 --- a/src/net/smtp/SMTPCommand.cpp +++ b/src/net/smtp/SMTPCommand.cpp @@ -87,30 +87,47 @@ ref <SMTPCommand> SMTPCommand::STARTTLS() // static -ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox) +ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); cmd << "MAIL FROM:<"; - vmime::utility::outputStreamAdapter cmd2(cmd); - mbox.getEmail().generate(cmd2); + if (utf8) + { + cmd << mbox.getEmail().toText().getConvertedText(vmime::charsets::UTF_8); + } + else + { + vmime::utility::outputStreamAdapter cmd2(cmd); + mbox.getEmail().generate(cmd2); + } cmd << ">"; + if (utf8) + cmd << " SMTPUTF8"; + return createCommand(cmd.str()); } // static -ref <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox) +ref <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); cmd << "RCPT TO:<"; - vmime::utility::outputStreamAdapter cmd2(cmd); - mbox.getEmail().generate(cmd2); + if (utf8) + { + cmd << mbox.getEmail().toText().getConvertedText(vmime::charsets::UTF_8); + } + else + { + vmime::utility::outputStreamAdapter cmd2(cmd); + mbox.getEmail().generate(cmd2); + } cmd << ">"; diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp index 30da3eff..cc3fc6ef 100644 --- a/src/net/smtp/SMTPTransport.cpp +++ b/src/net/smtp/SMTPTransport.cpp @@ -587,10 +587,13 @@ void SMTPTransport::send commands->addCommand(SMTPCommand::RSET()); // Emit the "MAIL" command + const bool hasSMTPUTF8 = + m_extensions.find("SMTPUTF8") != m_extensions.end(); + if (!sender.isEmpty()) - commands->addCommand(SMTPCommand::MAIL(sender)); + commands->addCommand(SMTPCommand::MAIL(sender, hasSMTPUTF8)); else - commands->addCommand(SMTPCommand::MAIL(expeditor)); + commands->addCommand(SMTPCommand::MAIL(expeditor, hasSMTPUTF8)); // Now, we will need to reset next time m_needReset = true; @@ -599,7 +602,7 @@ void SMTPTransport::send for (size_t i = 0 ; i < recipients.getMailboxCount() ; ++i) { const mailbox& mbox = *recipients.getMailboxAt(i); - commands->addCommand(SMTPCommand::RCPT(mbox)); + commands->addCommand(SMTPCommand::RCPT(mbox, hasSMTPUTF8)); } // Prepare sending of message data |