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 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 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 msg, utility::progressListener* progre vmime::ref hdr; } headerExchanger(msg, hdr); + send(msg, expeditor, recipients, progress, sender); +} + + +void transport::send + (ref 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 msg, + const mailbox& expeditor, + const mailboxList& recipients, + utility::progressListener* progress = NULL, + const mailbox& sender = mailbox()); + bool isSecuredConnection() const; ref 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 msg, + const mailbox& expeditor, + const mailboxList& recipients, + utility::progressListener* progress = NULL, + const mailbox& sender = mailbox()); + Type getType() const;