Issue #4: set envelope sender.
This commit is contained in:
parent
251cf21cee
commit
ff8827bdd3
@ -139,7 +139,7 @@ void sendmailTransport::noop()
|
|||||||
void sendmailTransport::send
|
void sendmailTransport::send
|
||||||
(const mailbox& expeditor, const mailboxList& recipients,
|
(const mailbox& expeditor, const mailboxList& recipients,
|
||||||
utility::inputStream& is, const utility::stream::size_type size,
|
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 no recipient/expeditor was found, throw an exception
|
||||||
if (recipients.isEmpty())
|
if (recipients.isEmpty())
|
||||||
@ -152,7 +152,12 @@ void sendmailTransport::send
|
|||||||
|
|
||||||
args.push_back("-i");
|
args.push_back("-i");
|
||||||
args.push_back("-f");
|
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("--");
|
args.push_back("--");
|
||||||
|
|
||||||
for (int i = 0 ; i < recipients.getMailboxCount() ; ++i)
|
for (int i = 0 ; i < recipients.getMailboxCount() ; ++i)
|
||||||
|
@ -560,9 +560,10 @@ void SMTPTransport::noop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SMTPTransport::send(const mailbox& expeditor, const mailboxList& recipients,
|
void SMTPTransport::send
|
||||||
utility::inputStream& is, const utility::stream::size_type size,
|
(const mailbox& expeditor, const mailboxList& recipients,
|
||||||
utility::progressListener* progress)
|
utility::inputStream& is, const utility::stream::size_type size,
|
||||||
|
utility::progressListener* progress, const mailbox& sender)
|
||||||
{
|
{
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
throw exceptions::not_connected();
|
throw exceptions::not_connected();
|
||||||
@ -586,7 +587,10 @@ void SMTPTransport::send(const mailbox& expeditor, const mailboxList& recipients
|
|||||||
commands->addCommand(SMTPCommand::RSET());
|
commands->addCommand(SMTPCommand::RSET());
|
||||||
|
|
||||||
// Emit the "MAIL" command
|
// 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
|
// Now, we will need to reset next time
|
||||||
m_needReset = true;
|
m_needReset = true;
|
||||||
|
@ -139,6 +139,21 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
|
|||||||
throw exceptions::no_expeditor();
|
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
|
// Extract recipients
|
||||||
mailboxList recipients;
|
mailboxList recipients;
|
||||||
|
|
||||||
@ -211,7 +226,7 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
|
|||||||
|
|
||||||
utility::inputStreamStringAdapter isAdapter(str);
|
utility::inputStreamStringAdapter isAdapter(str);
|
||||||
|
|
||||||
send(expeditor, recipients, isAdapter, str.length(), progress);
|
send(expeditor, recipients, isAdapter, str.length(), progress, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,13 @@ public:
|
|||||||
|
|
||||||
void noop();
|
void noop();
|
||||||
|
|
||||||
void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL);
|
void send
|
||||||
|
(const mailbox& expeditor,
|
||||||
|
const mailboxList& recipients,
|
||||||
|
utility::inputStream& is,
|
||||||
|
const utility::stream::size_type size,
|
||||||
|
utility::progressListener* progress = NULL,
|
||||||
|
const mailbox& sender = mailbox());
|
||||||
|
|
||||||
bool isSecuredConnection() const;
|
bool isSecuredConnection() const;
|
||||||
ref <connectionInfos> getConnectionInfos() const;
|
ref <connectionInfos> getConnectionInfos() const;
|
||||||
|
@ -68,7 +68,13 @@ public:
|
|||||||
|
|
||||||
void noop();
|
void noop();
|
||||||
|
|
||||||
void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL);
|
void send
|
||||||
|
(const mailbox& expeditor,
|
||||||
|
const mailboxList& recipients,
|
||||||
|
utility::inputStream& is,
|
||||||
|
const utility::stream::size_type size,
|
||||||
|
utility::progressListener* progress = NULL,
|
||||||
|
const mailbox& sender = mailbox());
|
||||||
|
|
||||||
bool isSecuredConnection() const;
|
bool isSecuredConnection() const;
|
||||||
ref <connectionInfos> getConnectionInfos() const;
|
ref <connectionInfos> getConnectionInfos() const;
|
||||||
|
@ -74,8 +74,15 @@ public:
|
|||||||
* @param is input stream provding message data (header + body)
|
* @param is input stream provding message data (header + body)
|
||||||
* @param size size of the message data
|
* @param size size of the message data
|
||||||
* @param progress progress listener, or NULL if not used
|
* @param progress progress listener, or NULL if not used
|
||||||
|
* @param sender envelope sender (if empty, expeditor will be used)
|
||||||
*/
|
*/
|
||||||
virtual void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL) = 0;
|
virtual void send
|
||||||
|
(const mailbox& expeditor,
|
||||||
|
const mailboxList& recipients,
|
||||||
|
utility::inputStream& is,
|
||||||
|
const utility::stream::size_type size,
|
||||||
|
utility::progressListener* progress = NULL,
|
||||||
|
const mailbox& sender = mailbox()) = 0;
|
||||||
|
|
||||||
|
|
||||||
Type getType() const;
|
Type getType() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user