[syslog-ng] [PATCH]: Experimental SMTP destination

Gergely Nagy algernon at balabit.hu
Sun Feb 20 20:18:40 CET 2011


> > The usage is something like this:
> > 
> >         destination d_smtp {
> >           smtp(
> >             host("localhost")
> >             port(25)
> >             mail_from("syslog-ng alert service <noreply at example.com>")
> >             rcpt_to("Admin #1 <admin at example.com>")
> >             rcpt_to("Admin #2 <admin2 at example.com>")
> >             subject("[ALERT] $LEVEL condition in $PROGRAM!")
> >             header("X-Program" "$PROGRAM")
> >             header("X-Facility" "$FACILITY")
> >             body("Hi!\nThe syslog-ng alerting service thinks you might be interested in the following message:\n $MSG\n-- \nsyslog-ng\n")
> >           );
> >         };
> 
> I'd love to get away a little bit from SMTP logic, and use option names
> that reflect more closely what the user sees in a MUA.
> 
> We might give a chance to specify all the rest of the details, but they
> should be the exception and not the rule.
> 
> smtp(
>             host("localhost")
>             port(25)
>             from("syslog-ng alert service <noreply at example.com>")
>             to("Admin #1 <admin at example.com>", "Admin #2 <admin2 at example.com>")
>             cc("Admin BOSS <admin.boss at example.com>")
>             bcc("Blind CC <blindcc at example.com>")
>             subject("[ALERT] $LEVEL condition in $PROGRAM!")
>             body("Hi!\nThe syslog-ng alerting service thinks you might be interested in the following message:\n $MSG\n-- \nsyslog-ng\n")
> 	    extra-header("X-Program", "$PROGRAM")
>           );

Noted, will adjust accordingly.

> I doubt it'd be useful to use templates within To/Cc/Bcc, but the rest should be templates, 
> with support for embedded newline characters. (headers can also contain embedded 
> newlines, by embedding NL and adding whitespace in the front of the upcoming line, 
> although I'm not sure how much MUAs like it).

That's a tricky one. I'd go the easy route and filter newlines, and
replace them with spaces in the headers. I'm not quite sure whether
libesmtp does it for us, I'll have to double check.

The other option of mangling them into an SMTP-acceptable format doesn't
seem to worth the complexity, unless it's in libesmtp already.

> The same syntax could perhaps be used by a possible "sendmail()" destination, which 
> could spawn the local sendmail binary, instead of directly using SMTP.

Rather do a variant of program() then, I'd say, which does a one-off
fork & launch for each message it receives, as opposed to a long running
process.

That, and a few template functions to help with the formatting should do
the trick.

-- 
|8]





More information about the syslog-ng mailing list