aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-06-18 13:04:12 +0000
committerVincent Richard <[email protected]>2013-06-18 13:04:12 +0000
commit1ae7d67ae0e0638d2c12294620d3a4b831c5bc83 (patch)
treee5993c737e9b27347471476930e8adbdbc87e496
parentFixed issue #44 for MSVC. (diff)
downloadvmime-1ae7d67ae0e0638d2c12294620d3a4b831c5bc83.tar.gz
vmime-1ae7d67ae0e0638d2c12294620d3a4b831c5bc83.zip
SMTPUTF8: generate Internationalized Email only if supported by SMTP server.
-rw-r--r--src/net/smtp/SMTPTransport.cpp28
-rw-r--r--src/net/transport.cpp8
-rw-r--r--vmime/net/smtp/SMTPTransport.hpp7
-rw-r--r--vmime/net/transport.hpp19
4 files changed, 62 insertions, 0 deletions
diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
index cc3fc6ef..65c999bf 100644
--- a/src/net/smtp/SMTPTransport.cpp
+++ b/src/net/smtp/SMTPTransport.cpp
@@ -35,11 +35,14 @@
#include "vmime/exception.hpp"
#include "vmime/platform.hpp"
#include "vmime/mailboxList.hpp"
+#include "vmime/message.hpp"
#include "vmime/utility/filteredStream.hpp"
#include "vmime/utility/stringUtils.hpp"
#include "vmime/utility/outputStreamSocketAdapter.hpp"
#include "vmime/utility/streamUtils.hpp"
+#include "vmime/utility/outputStreamAdapter.hpp"
+#include "vmime/utility/inputStreamStringAdapter.hpp"
#include "vmime/net/defaultConnectionInfos.hpp"
@@ -673,6 +676,31 @@ void SMTPTransport::send
}
+void SMTPTransport::send
+ (ref <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
+ utility::progressListener* progress, const mailbox& sender)
+{
+ // Generate the message with Internationalized Email support,
+ // if this is supported by the SMTP server
+ const bool hasSMTPUTF8 =
+ m_extensions.find("SMTPUTF8") != m_extensions.end();
+
+ std::ostringstream oss;
+ utility::outputStreamAdapter ossAdapter(oss);
+
+ generationContext ctx(generationContext::getDefaultContext());
+ ctx.setInternationalizedEmailSupport(hasSMTPUTF8);
+
+ msg->generate(ctx, ossAdapter);
+
+ const string& str(oss.str());
+
+ utility::inputStreamStringAdapter isAdapter(str);
+
+ send(expeditor, recipients, isAdapter, str.length(), progress, sender);
+}
+
+
void SMTPTransport::sendRequest(ref <SMTPCommand> cmd)
{
cmd->writeToSocket(m_socket);
diff --git a/src/net/transport.cpp b/src/net/transport.cpp
index 923441b7..88ea6773 100644
--- a/src/net/transport.cpp
+++ b/src/net/transport.cpp
@@ -215,6 +215,14 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
vmime::ref <vmime::header> hdr;
} headerExchanger(msg, hdr);
+ send(msg, expeditor, recipients, progress, sender);
+}
+
+
+void transport::send
+ (ref <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
+ utility::progressListener* progress, const mailbox& sender)
+{
// Generate the message, "stream" it and delegate the sending
// to the generic send() function.
std::ostringstream oss;
diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp
index c914afd7..19b27bee 100644
--- a/vmime/net/smtp/SMTPTransport.hpp
+++ b/vmime/net/smtp/SMTPTransport.hpp
@@ -76,6 +76,13 @@ public:
utility::progressListener* progress = NULL,
const mailbox& sender = mailbox());
+ void send
+ (ref <vmime::message> msg,
+ const mailbox& expeditor,
+ const mailboxList& recipients,
+ utility::progressListener* progress = NULL,
+ const mailbox& sender = mailbox());
+
bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
diff --git a/vmime/net/transport.hpp b/vmime/net/transport.hpp
index 5d599379..969d9df7 100644
--- a/vmime/net/transport.hpp
+++ b/vmime/net/transport.hpp
@@ -61,6 +61,8 @@ protected:
public:
/** Send a message over this transport service.
+ * The default implementation simply generates the whole message
+ * into a string and "streams" it via a inputStreamStringAdapter.
*
* @param msg message to send
* @param progress progress listener, or NULL if not used
@@ -84,6 +86,23 @@ public:
utility::progressListener* progress = NULL,
const mailbox& sender = mailbox()) = 0;
+ /** Send a message over this transport service.
+ * The default implementation simply generates the whole message
+ * into a string and "streams" it via a inputStreamStringAdapter.
+ *
+ * @param msg message to send
+ * @param expeditor expeditor mailbox
+ * @param recipients list of recipient mailboxes
+ * @param progress progress listener, or NULL if not used
+ * @param sender envelope sender (if empty, expeditor will be used)
+ */
+ virtual void send
+ (ref <vmime::message> msg,
+ const mailbox& expeditor,
+ const mailboxList& recipients,
+ utility::progressListener* progress = NULL,
+ const mailbox& sender = mailbox());
+
Type getType() const;