Hi list,
I'm having issues with a custom dev for markasjunk2 plugin. I want to access the header X-DSPAM-Signature using the following code:
// get dspam signature header (%s macro) if(preg_match("/%s/",$command)){ $MESSAGE = new rcube_message($uid); $dspam_signature = $MESSAGE->get_header('x-dspam-signature'); file_put_contents('/tmp/mark_dspam', "uid=$uid; signature=$dspam_signature\n"); $command = str_replace('%s', $dspam_signature,$command); }
And all I get is an empty string instead of the header's value:
# cat /tmp/mark_dspam uid=25; signature=
If I try to fetch the header 'subject' instead of x-dspam-signature, it works alright.
In the email, this header is present :
Date: Mon, 07 Feb 2011 15:16:48 -0500 From: Julien... User-Agent: Mozilla... MIME-Version: 1.0 To: julien... Subject: spam Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DSPAM-Result: Innocent X-DSPAM-Processed: Mon Feb 7 21:16:55 2011 X-DSPAM-Confidence: 0.9899 X-DSPAM-Improbability: 1 in 9809 chance of being spam X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 4d50533749761795657448
I can't use the imap_init hook because the code is located in the 'cmd_learn.php' driver and not in the main function (it's on purpose).
How can I access this header ?
Thanks, julien
List info: http://lists.roundcube.net/dev/ BT/aba52c80
On 02/07/2011 05:14 PM, Julien Vehent wrote:
Hi list,
I'm having issues with a custom dev for markasjunk2 plugin. I want to access the header X-DSPAM-Signature using the following code:
// get dspam signature header (%s macro) if(preg_match("/%s/",$command)){ $MESSAGE = new rcube_message($uid); $dspam_signature = $MESSAGE->get_header('x-dspam-signature'); file_put_contents('/tmp/mark_dspam', "uid=$uid; signature=$dspam_signature\n"); $command = str_replace('%s', $dspam_signature,$command); }
And all I get is an empty string instead of the header's value:
I did something equivalent based on the raw messages and a regex, but that's kind of heavy to get just one header....
I anybody has a more elegant solution, I'm up for it !
$raw_message = $rcmail->imap->get_raw_body($uid); preg_match("/X-DSPAM-Signature: (.*)/i",$raw_message, $match); $dspam_signature = $match[1]; $command = str_replace('%s', $dspam_signature,$command);
Julien _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80
On 07.02.2011 23:14, Julien Vehent wrote:
rcube_imap must know what headers do you expect.
// get dspam signature header (%s macro) if(preg_match("/%s/",$command)){
$RCMAIL->imap->fetch_add_headers .= ' x-dspam-signature';
$MESSAGE = new rcube_message($uid); $dspam_signature = $MESSAGE->get_header('x-dspam-signature');
or set 'fetch_headers' variable of imap_init hook. See show_additional_headers plugin.
On Tue, 08 Feb 2011 08:26:09 +0100, A.L.E.C wrote:
On 07.02.2011 23:14, Julien Vehent wrote:
rcube_imap must know what headers do you expect.
// get dspam signature header (%s macro) if(preg_match("/%s/",$command)){
$RCMAIL->imap->fetch_add_headers .= ' x-dspam-signature';
$MESSAGE = new rcube_message($uid); $dspam_signature = $MESSAGE->get_header('x-dspam-signature');
Hi alec, It gives me a strange behavior. It works when I mark as spam (fetch the x-dspam-signature, execute the command and move the message to Junk special folder). But when I do the opposite (mark as ham, from Junk to Inbox), it doesn't fetch the signature.
The block of code should is the same. So I don't understand.
// get dspam signature header (if %s macro is used) if(preg_match("/%s/",$command)){
$rcmail->imap->fetch_add_headers .= ' x-dspam-signature';
$MESSAGE = new rcube_message($uid);
$dspam_signature = $MESSAGE->get_header('x-dspam-signature');
$tmp_command = str_replace('%s', $dspam_signature,$command);
} exec($tmp_command, $output);
Note that when I parse directly the raw message using a regex, It works both ways.
or set 'fetch_headers' variable of imap_init hook. See show_additional_headers plugin.
I can't use imap_init hook in the markasjunk2 driver.
Thanks Julien _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80