DBL (Database Logging)
--------------------------------------------------------------
-This feature allows to write exim internal log information
+An arbitrary per-transport string can be expanded on successful delivery,
+and (for SMTP transports) a second string on deferrals caused by a host error.
+This feature allows the writing of exim internal log information
(not available otherwise) into a database.
-Initially implemented is logging of details about successfully
-completed remote deliveries, which are needed for reputation
-systems, and deferrals caused by a host error.
In order to use DBL, you must set
in your Local/Makefile
-and define the database queries in the runtime config file, to
+and define the expandable strings in the runtime config file, to
be executed at end of delivery.
Additionally, there are 8 more variables, available at end of
dbl_delivery_local_part local part of address being delivered
dbl_delivery_domain domain part of address being delivered
dbl_delivery_confirmation SMTP confirmation message
+router_name name of router
+transport_name name of transport
In case of a deferral caused by a host-error:
dbl_defer_errno Error number
dbl_defer_errstr Error string possibly containing more details
-To log successful deliveries, set the following option in the main
-option part of runtime config.
+
+To log successful deliveries, set the following option
+on any transport of interest.
dbl_delivery_query
'${quote_pgsql:${lc:$dbl_delivery_fqdn}}', \
'${quote_pgsql:$message_exim_id}')}}
+The string is expanded after the delivery completes and any
+side-effects will happen. The result is then discarded.
+Note that for complex operations an ACL expansion can be used.
+
In order to log host deferrals, add the following option to an SMTP
transport:
#ifdef EXPERIMENTAL_DBL
dbl_delivery_ip = NULL; /* presume no successful remote delivery */
+ dbl_delivery_port = 0;
+ dbl_delivery_fqdn = NULL;
+ dbl_delivery_local_part = NULL;
+ dbl_delivery_domain = NULL;
+ dbl_delivery_confirmation = NULL;
#endif
s = reset_point = store_get(size);
if (addr->transport->info->local)
{
if (addr->host_list != NULL)
+ {
s = string_append(s, &size, &ptr, 2, US" H=", addr->host_list->name);
+ #ifdef EXPERIMENTAL_DBL
+ dbl_delivery_fqdn = addr->host_list->name;
+ #endif
+ }
if (addr->shadow_message != NULL)
s = string_cat(s, &size, &ptr, addr->shadow_message,
Ustrlen(addr->shadow_message));
s = string_cat(s, &size, &ptr, US"*", 1);
#ifdef EXPERIMENTAL_DBL
- dbl_delivery_ip = string_copy(addr->host_used->address);
- dbl_delivery_port = addr->host_used->port;
- dbl_delivery_fqdn = string_copy(addr->host_used->name);
- dbl_delivery_local_part = string_copy(addr->local_part);
- dbl_delivery_domain = string_copy(addr->domain);
- dbl_delivery_confirmation = string_copy(addr->message);
+ dbl_delivery_ip = addr->host_used->address;
+ dbl_delivery_port = addr->host_used->port;
+ dbl_delivery_fqdn = addr->host_used->name;
+ dbl_delivery_local_part = addr->local_part;
+ dbl_delivery_domain = addr->domain;
+ dbl_delivery_confirmation = addr->message;
#endif
}
s[ptr] = 0;
log_write(0, flags, "%s", s);
+
#ifdef EXPERIMENTAL_DBL
-if (dbl_delivery_ip != NULL && dbl_delivery_query != NULL)
+if (addr->transport->dbl_delivery_query)
{
DEBUG(D_deliver)
{
- debug_printf(" DBL(Delivery): dbl_delivery_query=|%s| dbl_delivery_IP=%s\n", dbl_delivery_query, dbl_delivery_ip);
+ debug_printf(" DBL(Delivery): dbl_delivery_query=|%s| dbl_delivery_IP=%s\n",
+ addr->transport->dbl_delivery_query, dbl_delivery_ip);
}
- router_name = addr->router->name;
+ router_name = addr->router->name;
transport_name = addr->transport->name;
- expand_string(dbl_delivery_query);
+ expand_string(addr->transport->dbl_delivery_query);
router_name = NULL;
transport_name = NULL;
}
#ifdef EXPERIMENTAL_DBL
int dbl_defer_errno = 0;
uschar *dbl_defer_errstr = NULL;
-uschar *dbl_delivery_query = NULL;
uschar *dbl_delivery_ip = NULL;
int dbl_delivery_port = 0;
uschar *dbl_delivery_fqdn = NULL;
#ifdef EXPERIMENTAL_DBL
extern int dbl_defer_errno; /* error number set when a remote delivery is deferred with a host error */
extern uschar *dbl_defer_errstr; /* error string set when a remote delivery is deferred with a host error */
-extern uschar *dbl_delivery_query; /* query string to log delivery info in DB */
extern uschar *dbl_delivery_ip; /* IP of host, which has accepted delivery */
extern int dbl_delivery_port; /* port of host, which has accepted delivery */
extern uschar *dbl_delivery_fqdn; /* FQDN of host, which has accepted delivery */
{ "daemon_smtp_ports", opt_stringptr, &daemon_smtp_port },
{ "daemon_startup_retries", opt_int, &daemon_startup_retries },
{ "daemon_startup_sleep", opt_time, &daemon_startup_sleep },
-#ifdef EXPERIMENTAL_DBL
- { "dbl_delivery_query", opt_stringptr, &dbl_delivery_query },
-#endif
#ifdef EXPERIMENTAL_DCC
{ "dcc_direct_add_header", opt_bool, &dcc_direct_add_header },
{ "dccifd_address", opt_stringptr, &dccifd_address },
BOOL log_fail_output;
BOOL log_defer_output;
BOOL retry_use_local_part; /* Defaults true for local, false for remote */
+#ifdef EXPERIMENTAL_DBL
+ uschar *dbl_delivery_query; /* String to expand on success */
+#endif
} transport_instance;
(void *)offsetof(transport_instance, body_only) },
{ "current_directory", opt_stringptr|opt_public,
(void *)offsetof(transport_instance, current_dir) },
+#ifdef EXPERIMENTAL_DBL
+ { "dbl_delivery_query",opt_stringptr | opt_public,
+ (void *)offsetof(transport_instance, dbl_delivery_query) },
+#endif
{ "debug_print", opt_stringptr | opt_public,
(void *)offsetof(transport_instance, debug_string) },
{ "delivery_date_add", opt_bool|opt_public,
acl_smtp_rcpt = accept
acl_smtp_data = accept
-dbl_delivery_query = ${acl {logger}{delivery}}
-
# ----- ACL -----
port = PORT_S
command_timeout = 1s
final_timeout = 1s
+ dbl_delivery_query = ${acl {logger}{delivery}}
dbl_host_defer_query = ${acl {logger}{deferral}}
# End
QUIT
220 OK
****
-exim -d+deliver+expand+acl -qqf
+exim -qqf
****
#
#
EHLO
*sleep 4
****
-exim -d-all+deliver+acl+expand -odi userx@domain1.com
+exim -odi userx@domain1.com
A message which will hit a timeout
.
****