Bash email forwarding script #226
Replies: 3 comments
-
SELinux Save script in ruleset
install them
|
Beta Was this translation helpful? Give feedback.
-
very nice - many thanks for sharing! |
Beta Was this translation helpful? Give feedback.
-
I updated the script which now uses |
Beta Was this translation helpful? Give feedback.
-
Hey ho,
After some try and error I got a working bash script to forward system emails to this API.
My primary problem is thatmunpack
is not supplied within the default repositorys (or EPEL) for RHEL 8.After some googeling I found a extremely helpful post that got me started.
So here it is.
My little dirty way to redirect mails (even with multiple attachments) to Signal.
WARNING:
it is quiet easy to break or maybe even misuse this script with a preperated mail.
it may be possible to trigger a code execution from within the emails
What it does
This script may break your system.
send every other attachment afterwards
${large_attachment_dir}
and stay there until manual deletion.the
${message_recipient}
will receive a information about that.What it NOT does
POST
errors (send to API).Known problems
*.tar.gz
results in*.gz
only tested with*.jpg
and*.tar.gz
(is this another issue worth? Set file names of attachments #136)
Usage
Alias
/etc/aliases
Postfix
/etc/postfix/virtual
Script
/usr/local/bin/mail2signal.sh
Version 1
Requirements
(at least for me)
jq
Requirements
(at least for me)
jq
ripmime
Test
Without attachment
With attachment
${TESTFILE}
From remote system
Any idea or improvement is very welcome.
At some point I might redesign this script with some improvements and an eye on proper coding style.
Or may be able to write a python replacement.
But for now it does the trick for me.
EDIT1: add script requirements
EDIT2: script version 2 which uses
ripmime
instead ofgrep / tail / head / sed
Beta Was this translation helpful? Give feedback.
All reactions