]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-submit - Emit named events.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 2 Mar 2019 16:18:02 +0000 (17:18 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 2 Mar 2019 17:03:15 +0000 (18:03 +0100)
These have some overlap with the smtp-client events, but for the sendmail binary
submission method those are not produced.

src/lib-smtp/smtp-submit.c

index f0dd04f8610eb13c53b681733ecd9bf0229c3d66..85b52a28679e1a8e5e6d59326492dc65d01c3bd2 100644 (file)
@@ -117,6 +117,8 @@ smtp_submit_init(struct smtp_submit_session *session,
        p_array_init(&subm->rcpt_to, pool, 2);
 
        subm->event = event_create(session->event);
+       event_add_str(subm->event, "mail_from",
+                     smtp_address_encode(subm->mail_from));
 
        return subm;
 }
@@ -178,6 +180,8 @@ struct ostream *smtp_submit_send(struct smtp_submit *subm)
        i_assert(subm->output == NULL);
        i_assert(array_count(&subm->rcpt_to) > 0);
 
+       event_add_int(subm->event, "recipients", array_count(&subm->rcpt_to));
+
        subm->output = iostream_temp_create
                (t_strconcat("/tmp/dovecot.",
                        master_service_get_name(master_service), NULL), 0);
@@ -194,6 +198,16 @@ smtp_submit_callback(struct smtp_submit *subm, int status,
 
        timeout_remove(&subm->to_error);
 
+       struct event_passthrough *e =
+               event_create_passthrough(subm->event)->
+               set_name("smtp_submit_finished");
+       if (status > 0)
+               e_debug(e->event(), "Sent message successfully");
+       else {
+               e->add_str("error", error);
+               e_debug(e->event(), "Failed to send message: %s", error);
+       }
+
        i_zero(&result);
        result.status = status;
        result.error = error;
@@ -462,6 +476,7 @@ void smtp_submit_run_async(struct smtp_submit *subm,
                           smtp_submit_callback_t *callback, void *context)
 {
        const struct smtp_submit_settings *set = &subm->session->set;
+       uoff_t data_size;
 
        subm->callback = callback;
        subm->context = context;
@@ -470,6 +485,14 @@ void smtp_submit_run_async(struct smtp_submit *subm,
        subm->input = iostream_temp_finish
                (&subm->output, IO_BLOCK_SIZE);
 
+       if (i_stream_get_size(subm->input, TRUE, &data_size) > 0)
+               event_add_int(subm->event, "data_size", data_size);
+
+       struct event_passthrough *e =
+               event_create_passthrough(subm->event)->
+               set_name("smtp_submit_started");
+       e_debug(e->event(), "Started sending message");
+
        if (set->submission_host != NULL) {
                smtp_submit_send_host(subm);
        } else {