SMTPUTF8: generate Internationalized Email only if supported by SMTP server.
This commit is contained in:
parent
5137d6b0f9
commit
1ae7d67ae0
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user