/usr/bin/imp-bounce-spam is in php-horde-imp 6.1.6-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!/usr/bin/php
<?php
/**
* This script bounces a message back to the sender and can be used with IMP's
* spam reporting feature to bounce spam.
*
* It takes the orginal message from standard input and requires the bounce
* message in the file imp/config/bounce.txt. Important: the bounce message
* must be a complete message including headers!
*
* Copyright 2005-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
$baseFile = __DIR__ . '/../lib/Application.php';
if (file_exists($baseFile)) {
require_once $baseFile;
} else {
require_once 'PEAR/Config.php';
require_once PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/imp/lib/Application.php';
}
Horde_Registry::appInit('imp', array(
'authentication' => false,
'cli' => true
));
/** Configuration **/
/**
* Location of the bounce template.
* The following strings will be replaced in the template:
* %TO% - The spammer's e-mail address.
* %TARGET% - The target's e-mail address.
*/
$bounce_template = IMP_BASE . '/config/bounce.txt';
/** End Configuration **/
/* If there's no bounce template file then abort */
if (!file_exists($bounce_template)) {
$cli->fatal('Bounce template does not exist.');
}
/* Read the message content. */
$data = $cli->readStdin();
/* Who's the spammer? */
$headers = Horde_Mime_Headers::parseHeaders($data);
$return_path = $headers->getOb('return-path');
/* Who's the target? */
$delivered_to = $headers->getOb('delivered-to');
/* Read the bounce template and construct the mail */
$bounce = str_replace(
array('%TO%', '%TARGET%'),
array($return_path[0]->bare_address, $delivered_to[0]->bare_address),
file_get_contents($bounce_template)
);
/* Send the mail */
$sendmail = "/usr/sbin/sendmail -t -f ''";
$fd = popen($sendmail, 'w');
fputs($fd, preg_replace("/\n$/", "\r\n", $bounce . $data));
pclose($fd);
|