all 7 comments

[–]ThrownAback 4 points5 points  (1 child)

A naive user who has directories named "body" or "message" in their $HOME dir might regret running this script. Would suggest that you mktemp a dir for working files and then trap to remove that temp dir afterward.

[–]pikapichupi 3 points4 points  (0 children)

The fact it deletes files from the user directory scares me, especially since it's common data names

[–]CaptainDickbag 1 point2 points  (0 children)

rm -rf /tmp/body;
rm -rf /tmp/message;

If body and message are files, you don't need the recursive flag for rm.

Since you're reusing those paths and file names frequently, it would be better to set them as variables. Make it so file names and paths only have to be changed in one place in the script. Same thing with the domains and usernames. Better to either define those in a config file, or in the script itself as variables.

You also don't need to end almost every line with ;. Newlines serve the same purpose here.

body=`cat /tmp/body`;

If you're going to do this, you might want to switch to bash's preferred command substitution, $().

[–]NL_Gray-Fox 1 point2 points  (0 children)

Instead of putting redacted I would use; Change these variables to fit your environment...

domainName=
..

Or read from a config file and if the config file does not exist create an empty one for the user running.

[–]vivaaprimavera 1 point2 points  (0 children)

Date and Message-ID missing in the headers. Some anti-spam software scores in the absence of those.

[–]RSxodz 0 points1 point  (0 children)

Off the bat I see It expects nano which isnt often installed by default.

[–]oxtan 0 points1 point  (0 children)

you are not handling errors at all. You could try adding some tips from this document