smtp-server-transaction.c revision 499ca6dc5d746fd7a7efc6d497deede89553669f
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainensmtp_server_transaction_create(struct smtp_server_connection *conn,
4b058f90f9e8a2c6b2eed275de4eb8cc5195a71dTimo Sirainen /* create new transaction */
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen pool = pool_alloconly_create("smtp server transaction", 512);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen trans = p_new(pool, struct smtp_server_transaction, 1);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen /* generate transaction ID */
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen str_truncate(id, str_len(id)-2); /* drop trailing "==" */
0f66f12eb4cdbf47670975044c88d8f388bf92dfTimo Sirainen trans->mail_from = smtp_address_clone(trans->pool, mail_from);
6a9f9a5101b665fd2ef80c9e048a5eace78e01efTimo Sirainen smtp_params_mail_copy(pool, &trans->params, params);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid smtp_server_transaction_free(struct smtp_server_transaction **_trans)
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen struct smtp_server_transaction *trans = *_trans;
1f57716285d4c5bc9bf2fd5569e3c85fd496afd9Timo Sirainen if (smtp_address_equals(drcpt->path, rcpt->path) &&
1f57716285d4c5bc9bf2fd5569e3c85fd496afd9Timo Sirainen smtp_params_rcpt_equals(&drcpt->params, &rcpt->params))
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainensmtp_server_transaction_add_rcpt(struct smtp_server_transaction *trans,
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen rcpt = p_new(trans->pool, struct smtp_server_recipient, 1);
a3ea111cfdbfd4f32baeb0bd7f1d72568c60a023Timo Sirainen rcpt->path = smtp_address_clone(trans->pool, rcpt_to);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen smtp_params_rcpt_copy(trans->pool, &rcpt->params, params);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen p_array_init(&trans->rcpt_to, trans->pool, 8);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenbool smtp_server_transaction_has_rcpt(struct smtp_server_transaction *trans)
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainensmtp_server_transaction_rcpt_count(struct smtp_server_transaction *trans)
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvoid smtp_server_transaction_fail_data(struct smtp_server_transaction *trans,
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainen const char *msg;
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainen unsigned int count, i;
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainen for (i = 0; i < count; i++) {
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainenvoid smtp_server_transaction_write_trace_record(string_t *str,
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainen struct smtp_server_connection *conn = trans->conn;
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainen const struct smtp_server_helo_data *helo_data = &conn->helo;
b09be485e9373be4288f5615bbce6ebed65a425aTimo Sirainen rcpt_to = smtp_address_encode(rcpts[0]->path);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen /* (using) */