diff options
| author | Vincent Richard <[email protected]> | 2013-04-03 09:02:15 +0200 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2013-04-03 09:02:15 +0200 |
| commit | ff8827bdd33da077d4677cc7589449cfa36d8b87 (patch) | |
| tree | 71cd41898af157ec18f7e472c1065c97af60d3dc /src | |
| parent | Remove +x bit from source files (diff) | |
| download | vmime-ff8827bdd33da077d4677cc7589449cfa36d8b87.tar.gz vmime-ff8827bdd33da077d4677cc7589449cfa36d8b87.zip | |
Issue #4: set envelope sender.
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/sendmail/sendmailTransport.cpp | 9 | ||||
| -rw-r--r-- | src/net/smtp/SMTPTransport.cpp | 12 | ||||
| -rw-r--r-- | src/net/transport.cpp | 17 |
3 files changed, 31 insertions, 7 deletions
diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp index dbbb55a8..82501575 100644 --- a/src/net/sendmail/sendmailTransport.cpp +++ b/src/net/sendmail/sendmailTransport.cpp @@ -139,7 +139,7 @@ void sendmailTransport::noop() void sendmailTransport::send (const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, - utility::progressListener* progress) + utility::progressListener* progress, const mailbox& sender) { // If no recipient/expeditor was found, throw an exception if (recipients.isEmpty()) @@ -152,7 +152,12 @@ void sendmailTransport::send args.push_back("-i"); args.push_back("-f"); - args.push_back(expeditor.getEmail().generate()); + + if (!sender.isEmpty()) + args.push_back(expeditor.getEmail().generate()); + else + args.push_back(sender.getEmail().generate()); + args.push_back("--"); for (int i = 0 ; i < recipients.getMailboxCount() ; ++i) diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp index b95321f9..853ffe35 100644 --- a/src/net/smtp/SMTPTransport.cpp +++ b/src/net/smtp/SMTPTransport.cpp @@ -560,9 +560,10 @@ void SMTPTransport::noop() } -void SMTPTransport::send(const mailbox& expeditor, const mailboxList& recipients, - utility::inputStream& is, const utility::stream::size_type size, - utility::progressListener* progress) +void SMTPTransport::send + (const mailbox& expeditor, const mailboxList& recipients, + utility::inputStream& is, const utility::stream::size_type size, + utility::progressListener* progress, const mailbox& sender) { if (!isConnected()) throw exceptions::not_connected(); @@ -586,7 +587,10 @@ void SMTPTransport::send(const mailbox& expeditor, const mailboxList& recipients commands->addCommand(SMTPCommand::RSET()); // Emit the "MAIL" command - commands->addCommand(SMTPCommand::MAIL(expeditor)); + if (!sender.isEmpty()) + commands->addCommand(SMTPCommand::MAIL(sender)); + else + commands->addCommand(SMTPCommand::MAIL(expeditor)); // Now, we will need to reset next time m_needReset = true; diff --git a/src/net/transport.cpp b/src/net/transport.cpp index 1e2936ce..923441b7 100644 --- a/src/net/transport.cpp +++ b/src/net/transport.cpp @@ -139,6 +139,21 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre throw exceptions::no_expeditor(); } + // Extract sender + mailbox sender; + + try + { + const mailbox& mbox = *msg->getHeader()->findField(fields::SENDER)-> + getValue().dynamicCast <const mailbox>(); + + sender = mbox; + } + catch (exceptions::no_such_field&) + { + sender = expeditor; + } + // Extract recipients mailboxList recipients; @@ -211,7 +226,7 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre utility::inputStreamStringAdapter isAdapter(str); - send(expeditor, recipients, isAdapter, str.length(), progress); + send(expeditor, recipients, isAdapter, str.length(), progress, sender); } |
