[syslog-ng] [PATCH] afsmtp: New destination driver, to send mails via SMTP.

Gergely Nagy algernon at balabit.hu
Sun Feb 5 02:00:49 CET 2012


Patrick Hemmer <syslogng at stormcloud9.net> writes:

> This looks like it'll be fairly useful, but I do have one suggestion, 
> support the `dest_writer_option` parameters. Specifically flush 
> lines/timeout and template.

Hrm... I forgot to do that? I distinctly remember something about this,
but that might have been some other module I worked on recently.

> I can imagine using this to send an email notification on critical 
> alerts, and often you'll get a batch of several messages marked as 
> critical. So instead of having a separate email for every message, a 
> flush_timeout could be used to only send the email once we've waited a 
> second or so for them all to come in.

Mhm, this is something I want the driver to be able to perform, but it's
a bit tricky to implement it properly. I'll see what I can do,
though. Thanks for the suggestion!

> Template would also be useful, but not as important as the flush 
> parameters I think. The template should be able to control the contents 
> of the email body.

The body() argument is there, and it's a template. You can control the
recipients (to, cc, bcc), the sender (from & reply-to), custom headers
(header) and the body: all of these are templates, you're free to do
whatever weird thing you can come up with.

> Couple arguments for this. First is that emails are 
> generally multi-line, so being able to have a template like "Host: 
> $HOST\nProgram: $PROGRAM\nMessage: $MSGONLY\n\n" would make for nice 
> easy reading.

body("Host: $HOST\nProgram: $PROGRAM\n...") does just that. ;)

> Second is that this might be used to send to pagers or 
> mobile phones where message length is limited, so being able to set the 
> template and get only the necessary information is important.

Combined with the $(substr) template function, I believe you can set a
maximum length too. Something like:

body("$(substr ${MESSAGE} 0 140)")

So, the driver already supports templates, and you can limit the length
of everything. ;)

-- 
|8]



More information about the syslog-ng mailing list