aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emailAddress.cpp11
-rw-r--r--src/net/smtp/SMTPCommand.cpp29
-rw-r--r--src/net/smtp/SMTPTransport.cpp9
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