Procmail has no built-in mechanism to forward as attachment. However, a simple shell script does the trick. In fact, spamcop.net offers a simple Perl script for exactly this purpose.
Download this script, edit in your eMail addresses and make it executable, let's say as $HOME/bin/reporter.pl
.
Then, in your .procmailrc
use the action |
("pipe" or "filter") instead of !
("forward"). For instance:
:0fw
| /usr/bin/spamassassin
:0w
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*
| $HOME/bin/reporter.pl
:0H:
* ^X-Spam-Status: Yes
./Spam
Note that the 2nd recipe does not use the flag "f" (filter). With "f" procmail would expect the script to return a message at stdout. That's the case e.g. with "|spamassassin", but our "|reporter.pl" is a so-called delivering recipe. It should not create any output. Hence, /dev/null
is not needed.
Edit
As tripleee pointed out messages can also be forwarded "inline", and SpamCop.net is accepting and processing this format apparently just fine. So, adapting tripleee's code the recipe could be
:0fw
| /usr/bin/spamassassin
:0w
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*
| (echo "From: me@example.com"; echo "To: submit.[id]@spam.spamcop.net"; \
echo "Subject: report spam"; echo "MIME-Version: 1.0"; \
echo "Content-type: message/rfc822"; echo; cat -) | $SENDMAIL -t
:0H:
* ^X-Spam-Status: Yes
./Spam