Using a date in a bcc map

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Using a date in a bcc map

@lbutlr
[This message bounced because the words "c h a n g e" and "a d d r e s s" were on the same line.]

I currently have recipient_bcc.pcre:

if !/backup.*@/
/^([^+_]*).*@(.*)/   backup+${1}.${2}@localdomain.tld
endif

I would like to change
this to add a date field
to the backup address.

(I am planning on using date +%j or maybe +%G%m%d)

But I can't figure out how I could do this since I don't think there is anyway to execute date +%j in a map.

Basically, if I can get the date I want into $3

/^([^+_]*).*@(.*)/   backup+${3).${1}.${2}@localdomain.tld

Also, if I wanted to put a specific list of domains in the match on the left, is the bast way simply to list them inside the match, or to list each one on a separate line?

--
Apple broke AppleScripting signatures in Mail.app, so no random signatures.

Reply | Threaded
Open this post in threaded view
|

Re: Using a date in a bcc map

Ralf Hildebrandt-2
* @lbutlr <[hidden email]>:

> [This message bounced because the words "c h a n g e" and "a d d r e s s" were on the same line.]
>
> I currently have recipient_bcc.pcre:
>
> if !/backup.*@/
> /^([^+_]*).*@(.*)/   backup+${1}.${2}@localdomain.tld
> endif
>
> I would like to change
> this to add a date field
> to the backup address.

Try creating the recipient_bcc.pcre using a script, and let the scipt
insert the date.

Nice idea!

--
[*] sys4 AG

https://sys4.de, +49 (89) 30 90 46 64
Schleißheimer Straße 26/MG, 80333 München
                                           
Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein
Reply | Threaded
Open this post in threaded view
|

Re: Using a date in a bcc map

@lbutlr
On Sep 8, 2017, at 05:30, Ralf Hildebrandt <[hidden email]> wrote:
>
> Try creating the recipient_bcc.pcre using a script, and let the scipt
> insert the date.

So recipient_bcc.pcre is not simply loaded at startup? Is it read each time (seems unlikely) or simply periodically refreshed, or does my script to write the map need to thump postfix?

> Nice idea!

Thanks. It seems like it will be useful.

--
This is my signature. There are many like it, but this one is mine.
Reply | Threaded
Open this post in threaded view
|

Re: Using a date in a bcc map

Wietse Venema
LuKreme:
> On Sep 8, 2017, at 05:30, Ralf Hildebrandt <[hidden email]> wrote:
> >=20
> > Try creating the recipient_bcc.pcre using a script, and let the scipt
> > insert the date.
>
> So recipient_bcc.pcre is not simply loaded at startup? Is it read each time (=
> seems unlikely) or simply periodically refreshed, or does my script to write=
>  the map need to thump postfix?

According to the cleanup manpage:

CONFIGURATION PARAMETERS
       Changes to main.cf are picked up automatically, as cleanup(8) processes
       run for only a limited amount of time. Use the command "postfix reload"
       to speed up a change.

That also applies to the content of lookup tables that are used by the
cleanup daemon.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Using a date in a bcc map

@lbutlr
On 08 Sep 2017, at 09:53, Wietse Venema <[hidden email]> wrote:
> CONFIGURATION PARAMETERS
>       Changes to main.cf are picked up automatically, as cleanup(8) processes
>       run for only a limited amount of time. Use the command "postfix reload"
>       to speed up a change.

Right, I knew that.

> That also applies to the content of lookup tables that are used by the
> cleanup daemon.

I did not know that, however. Thanks.

The script is stupidly simple, but I will include it anyway in case anyone cares:

#!/bin/bash

JDATE=$(gdate +%j)
cat << EOF > /etc/postfix/recipient_bcc.pcre
if !/backup.*@/
/^([^+_]*).*@([^.]*)/   backup+${JDATE}.\${1}-\${2}@southgaylord.com
endif

EOF

this results in a maildir for today for my list email address of

.251.kremels-kreme

Which is certainly easier to sort and search through than the previous method, especially if I use an MUA instead of doing everything via the shell.

I was torn on doing the SI date, but decided since the backups are only short term, there was no reason not to simply use the day of the year for sorting.

I use cron to run it at midnight

--
Apple broke AppleScripting signatures in Mail.app, so no random signatures.