Roundcube Community Forum

Miscellaneous => Roundcube Discussion => Topic started by: nlreeftank on November 15, 2012, 10:16:06 AM

Title: Injecting responds text when replying to a mail
Post by: nlreeftank on November 15, 2012, 10:16:06 AM
Hi,

How can i do this?


When i open up a mail in roundcube i wanna parse the senders email and inject a text to the reply body of that mail.
Im a php programmer, just have to know in wich files i have todo this.


Greetz
Gerd
Title: Re: Injecting responds text when replying to a mail
Post by: nlreeftank on November 15, 2012, 12:01:59 PM
I checked out the api of roundcube and found a hook i think i can use for this: message_compose

Where can i find a list of variables that i can use within the hooks?
Title: Re: Injecting responds text when replying to a mail
Post by: SKaero on November 15, 2012, 04:50:58 PM
http://trac.roundcube.net/wiki/Plugin_Hooks#message_compose
Title: Re: Injecting responds text when replying to a mail
Post by: nlreeftank on November 15, 2012, 06:27:03 PM
any helping hand, why doesn this replace the body?

<?php
/**
* veranderd_body
* @version 1.0
* @author Gerd K
* @url http://www.domain.com
*/
class verander_body extends rcube_plugin
{

 public $task = 'mail';

 function init()
 {
   $this->add_hook('message_compose', array($this, 'replace'));
 
 }


 function replace($args)
 {
   $args['body'] = "TEST TEST";
    return $args;
 }
}

?>
Title: Re: Injecting responds text when replying to a mail
Post by: SKaero on November 15, 2012, 07:27:09 PM
The body is in $args['body'] if you do the following:

$args['body'] = "TEST TEST";

it will replace the body.

If you want prepend do the following:

$args['body'] = "TEST TEST" . $args['body'];
Title: Re: Injecting responds text when replying to a mail
Post by: nlreeftank on November 15, 2012, 07:30:43 PM
it doesnt seem todo that

<?php
/**
* verander_body
*
* Sample plugin to replace emoticons in plain text message body with real icons
*
* @version 1.0
* @author Gerd Koetje
* @url http://www.pobb.nl
*/
class verander_body extends rcube_plugin
{

 public $task = 'mail';

 function init()
 {
   $this->add_hook('message_compose', array($this, 'replace'));
 
 }


 function replace($args)
 {

$args['body'] = "TEST TEST";

 }
}


?>


same when i return args

in my config i have

$rcmail_config['plugins'] = array('verander_body');
Title: Re: Injecting responds text when replying to a mail
Post by: SKaero on November 15, 2012, 07:50:23 PM
Reading back I see that you want to work with the reply, in which case you need to work use the message_compose_body hook.
Title: Re: Injecting responds text when replying to a mail
Post by: nlreeftank on November 15, 2012, 07:52:25 PM
that does the trick, thanks

how do i get the from variable from $this?

i tryed

$this->message->from;