X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fdeliver.c;h=4624719f853ed84c9ae462dddd123bd3fe452c95;hb=e30f4f43de211b14bd405a3d0e1579b9bd814908;hp=1cf757d69b8578550c2217ea194ed45ac4c99a7c;hpb=7ea1237c783e380d7bdb86c90b13d8203c7ecf26;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/deliver.c b/src/src/deliver.c index 1cf757d69..4624719f8 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -877,20 +877,33 @@ const uschar * save_host = deliver_host; const uschar * save_address = deliver_host_address; const int save_port = deliver_host_port; -if (!addr->transport) - return; - router_name = addr->router ? addr->router->name : NULL; -transport_name = addr->transport->name; deliver_domain = addr->domain; deliver_localpart = addr->local_part; deliver_host = addr->host_used ? addr->host_used->name : NULL; -(void) event_raise(addr->transport->event_action, event, - addr->host_used - || Ustrcmp(addr->transport->driver_name, "smtp") == 0 - || Ustrcmp(addr->transport->driver_name, "lmtp") == 0 - ? addr->message : NULL); +if (!addr->transport) + { + if (Ustrcmp(event, "msg:fail:delivery") == 0) + { + /* An address failed with no transport involved. This happens when + a filter was used which triggered a fail command (in such a case + a transport isn't needed). Convert it to an internal fail event. */ + + (void) event_raise(event_action, US"msg:fail:internal", addr->message); + } + } +else + { + transport_name = addr->transport->name; + + (void) event_raise(addr->transport->event_action, event, + addr->host_used + || Ustrcmp(addr->transport->driver_name, "smtp") == 0 + || Ustrcmp(addr->transport->driver_name, "lmtp") == 0 + || Ustrcmp(addr->transport->driver_name, "autoreply") == 0 + ? addr->message : NULL); + } deliver_host_port = save_port; deliver_host_address = save_address; @@ -1383,6 +1396,16 @@ failure_log(address_item * addr, uschar * driver_kind, uschar * now) void * reset_point; gstring * g = reset_point = string_get(256); +#ifndef DISABLE_EVENT +/* Message failures for which we will send a DSN get their event raised +later so avoid doing it here. */ + +if ( !addr->prop.ignore_error + && !(addr->dsn_flags & (rf_dsnflags & ~rf_notify_failure)) + ) + msg_event_raise(US"msg:fail:delivery", addr); +#endif + /* Build up the log line for the message and main logs */ /* Create the address string for logging. Must not do this earlier, because @@ -1431,10 +1454,6 @@ else log_write(0, LOG_MAIN, "** %s", g->s); -#ifndef DISABLE_EVENT -msg_event_raise(US"msg:fail:delivery", addr); -#endif - store_reset(reset_point); return; } @@ -3296,8 +3315,8 @@ small items (less than PIPE_BUF, which seems to be at least 512 in any Unix and often bigger) so even if we are reading while the subprocess is still going, we should never have only a partial item in the buffer. -hs12: This assumption is not true anymore, since we got quit large items (certificate -information and such) +hs12: This assumption is not true anymore, since we get quite large items (certificate +information and such). Argument: poffset the offset of the parlist item @@ -4666,12 +4685,10 @@ all pipes, so I do not see a reason to use non-blocking IO here search_tidyup(); - if ((pid = fork()) == 0) { int fd = pfd[pipe_write]; host_item *h; - DEBUG(D_deliver) debug_selector |= D_pid; // hs12 /* Setting this global in the subprocess means we need never clear it */ transport_name = tp->name; @@ -5569,7 +5586,8 @@ message size. This use of strcpy() is OK because the length id is checked when it is obtained from a command line (the -M or -q options), and otherwise it is known to be a valid message id. */ -Ustrcpy(message_id, id); +if (id != message_id) + Ustrcpy(message_id, id); f.deliver_force = forced; return_count = 0; message_size = 0; @@ -7254,7 +7272,6 @@ for (addr_dsntmp = addr_succeed; addr_dsntmp; addr_dsntmp = addr_dsntmp->next) if ( ( addr_dsntmp->dsn_aware != dsn_support_yes || addr_dsntmp->dsn_flags & rf_dsnlasthop ) - && addr_dsntmp->dsn_flags & rf_dsnflags && addr_dsntmp->dsn_flags & rf_notify_success ) { @@ -7321,11 +7338,9 @@ if (addr_senddsn) addr_dsntmp = addr_dsntmp->next) fprintf(f, "<%s> (relayed %s)\n\n", addr_dsntmp->address, - (addr_dsntmp->dsn_flags & rf_dsnlasthop) == 1 - ? "via non DSN router" - : addr_dsntmp->dsn_aware == dsn_support_no - ? "to non-DSN-aware mailer" - : "via non \"Remote SMTP\" router" + addr_dsntmp->dsn_flags & rf_dsnlasthop ? "via non DSN router" + : addr_dsntmp->dsn_aware == dsn_support_no ? "to non-DSN-aware mailer" + : "via non \"Remote SMTP\" router" ); fprintf(f, "--%s\n" @@ -7360,7 +7375,7 @@ if (addr_senddsn) addr_dsntmp->host_used->name); else fprintf(f, "Diagnostic-Code: X-Exim; relayed via non %s router\n\n", - (addr_dsntmp->dsn_flags & rf_dsnlasthop) == 1 ? "DSN" : "SMTP"); + addr_dsntmp->dsn_flags & rf_dsnlasthop ? "DSN" : "SMTP"); } fprintf(f, "--%s\nContent-type: text/rfc822-headers\n\n", bound); @@ -7441,14 +7456,16 @@ while (addr_failed) mark the recipient done. */ if ( addr_failed->prop.ignore_error - || ( addr_failed->dsn_flags & rf_dsnflags - && (addr_failed->dsn_flags & rf_notify_failure) != rf_notify_failure - ) ) + || addr_failed->dsn_flags & (rf_dsnflags & ~rf_notify_failure) + ) { addr = addr_failed; addr_failed = addr->next; if (addr->return_filename) Uunlink(addr->return_filename); +#ifndef DISABLE_EVENT + msg_event_raise(US"msg:fail:delivery", addr); +#endif log_write(0, LOG_MAIN, "%s%s%s%s: error ignored", addr->address, !addr->parent ? US"" : US" <", @@ -8080,8 +8097,8 @@ else if (addr_defer != (address_item *)(+1)) if ( !f.queue_2stage && delivery_attempted - && ( ((addr_defer->dsn_flags & rf_dsnflags) == 0) - || (addr_defer->dsn_flags & rf_notify_delay) == rf_notify_delay + && ( !(addr_defer->dsn_flags & rf_dsnflags) + || addr_defer->dsn_flags & rf_notify_delay ) && delay_warning[1] > 0 && sender_address[0] != 0