Package: apticron Version: 1.1.57 Severity: wishlist Tags: patch Dear Maintainer,
to remote controll our ticketing system, we had add custom mail headers to the reports send by apticron. The attached patch allows us to do so at least with bsd-mailx. I don't know how others mailx implementation might work. With tha attached patch, you can simply configure as many e-mail headers as desired by adding a CUSTOM_HEADER[x] array to /etc/apticron/apticron.conf: CUSTOM_HEADER[1]="X-OTRS-Priority: 3 normal - prio 3" CUSTOM_HEADER[2]="X-OTRS-Queue: foo::bar::baz" CUSTOM_HEADER[3]="X-OTRS-Service: Linux Operating System" CUSTOM_HEADER[4]="X-OTRS-SenderType: system" CUSTOM_HEADER[5]="X-OTRS-Loop: false" CUSTOM_HEADER[6]="X-OTRS-DynamicField-foo: bar" Best regards, Alexander PS: Thanks to Ansgar Burchardt for recommending the usage of arrays for this.
--- /usr/sbin/apticron 2014-10-01 18:27:20.000000000 +0200 +++ apticron 2018-06-13 11:38:29.862441874 +0200 @@ -16,18 +16,17 @@ else # bsd-mailx/mailutils' mailx don't do character set # conversion, but do not support MIME either. + MAILX_CMD='/usr/bin/mailx' + MAILX_CMD_ARGS=("-a" "MIME-Version: 1.0" "-a" "Content-type: text/plain; charset=UTF-8" "-a" "Content-transfer-encoding: 8bit") + + for hdr in "${CUSTOM_HEADER[@]}" ; do + MAILX_CMD_ARGS+=("-a" "${hdr}") + done + if [ -n "$CUSTOM_FROM" ] ; then - /usr/bin/mailx -a "MIME-Version: 1.0" \ - -a "Content-type: text/plain; charset=UTF-8" \ - -a "Content-transfer-encoding: 8bit" \ - -a "From: $CUSTOM_FROM" \ - "$@" - else - /usr/bin/mailx -a "MIME-Version: 1.0" \ - -a "Content-type: text/plain; charset=UTF-8" \ - -a "Content-transfer-encoding: 8bit" \ - "$@" + MAILX_CMD_ARGS+=("-a" "From: $CUSTOM_FROM") fi + $MAILX_CMD "${MAILX_CMD_ARGS[@]}" "$@" fi }