Skip to content

Commit

Permalink
lib-smtp: client: transaction: Add support for pipelining more than a…
Browse files Browse the repository at this point in the history
… single MAIL command.
  • Loading branch information
stephanbosch authored and villesavolainen committed Feb 12, 2019
1 parent e14794f commit 29fe17d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/lib-smtp/smtp-client-transaction.c
Expand Up @@ -595,6 +595,29 @@ smtp_client_transaction_mail_cb(const struct smtp_reply *reply,
}
}

#undef smtp_client_transaction_add_mail
void smtp_client_transaction_add_mail(
struct smtp_client_transaction *trans,
const struct smtp_address *mail_from,
const struct smtp_params_mail *mail_params,
smtp_client_command_callback_t *mail_callback, void *context)
{
struct smtp_client_transaction_mail *mail;

smtp_client_transaction_debug(trans, "Add MAIL command");

i_assert(!trans->data_provided);
i_assert(!trans->reset);

i_assert(trans->state < SMTP_CLIENT_TRANSACTION_STATE_RCPT_TO);

mail = smtp_client_transaction_mail_new(trans, mail_from, mail_params);
mail->mail_callback = mail_callback;
mail->context = context;

smtp_client_transaction_submit(trans, FALSE);
}

static void smtp_client_transaction_connection_ready(
struct smtp_client_transaction *trans)
{
Expand Down
21 changes: 21 additions & 0 deletions src/lib-smtp/smtp-client-transaction.h
Expand Up @@ -68,6 +68,27 @@ void smtp_client_transaction_start(struct smtp_client_transaction *trans,
context + CALLBACK_TYPECHECK(mail_callback, void (*)( \
const struct smtp_reply *reply, typeof(context))))

/* Add an extra pipelined MAIL command to the transaction. The mail_callback is
called once the server replies to the MAIL command. This is usually only
useful for forwarding pipelined SMTP transactions, which can involve more
than a single MAIL command (e.g. to have an implicit fallback sender address
in the pipeline when the first one fails). Of course, only one MAIL command
will succeed and therefore error replies for the others will not abort the
transaction. */
void smtp_client_transaction_add_mail(
struct smtp_client_transaction *trans,
const struct smtp_address *mail_from,
const struct smtp_params_mail *mail_params,
smtp_client_command_callback_t *mail_callback, void *context)
ATTR_NULL(3,5);
#define smtp_client_transaction_add_mail(trans, \
mail_from, mail_params, mail_callback, context) \
smtp_client_transaction_add_mail(trans, mail_from + \
CALLBACK_TYPECHECK(mail_callback, void (*)( \
const struct smtp_reply *reply, typeof(context))), \
mail_params, \
(smtp_client_command_callback_t *)mail_callback, context)

/* Add recipient to the transaction with a RCPT TO command. The
rcpt_to_callback is called once the server replies to the RCPT TO command.
If RCPT TO succeeded, the data_callback is called once the server replies
Expand Down

0 comments on commit 29fe17d

Please sign in to comment.