I would like to write a plugin that enables the user to specify an external SMTP server for every identity. But there are some questions I got.
I startet and used the identity_form hook to inject the additional form elements, but how am I supposed to get the values that were entered by the user? identity_update and identity_create do not provide the additional data to my plugin. And of course the data is not saved automatically.
Second question: When I get the data, how is a plugin supposed to save data? Do I save the data with:
rcmail::get_instance()->user->save_prefs(array('key' => $value));
or is there a way to save the data right where the identity is saved?
I hope you can help me developing this plugin.
Old thread: http://lists.roundcube.net/mail-archive/dev/2008-02/0000032.html _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80
On Tue, Aug 9, 2011 at 17:15, Florian Mutter elm@skweez.net wrote:
I would like to write a plugin that enables the user to specify an external SMTP server for every identity. But there are some questions I got.
I startet and used the identity_form hook to inject the additional form elements, but how am I supposed to get the values that were entered by the user? identity_update and identity_create do not provide the additional data to my plugin. And of course the data is not saved automatically.
To get the submitted data simply use $_POST['myvar'] or better get_input_value('myvar', RCUBE_INPUT_POST);
Second question: When I get the data, how is a plugin supposed to save data? Do I save the data with:
rcmail::get_instance()->user->save_prefs(array('key' => $value));
or is there a way to save the data right where the identity is saved?
This is up to the plugin developer... either you use user prefs or you extend the identities database table. With the latter option you can copy the submitted data right into the 'record' property of the 'identity_update' hook and they'll be stored with the identities record.
Since Roundcube doesn't (yet) provide an install routine or script for plugins, you have to mention the schema changes in a README file and hope that people read it :-)
Regards, Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80
Am 12.08.2011 um 21:05 schrieb Thomas Bruederli:
On Tue, Aug 9, 2011 at 17:15, Florian Mutter elm@skweez.net wrote:
I would like to write a plugin that enables the user to specify an external SMTP server for every identity. But there are some questions I got.
I startet and used the identity_form hook to inject the additional form elements, but how am I supposed to get the values that were entered by the user? identity_update and identity_create do not provide the additional data to my plugin. And of course the data is not saved automatically.
To get the submitted data simply use $_POST['myvar'] or better get_input_value('myvar', RCUBE_INPUT_POST);
Second question: When I get the data, how is a plugin supposed to save data? Do I save the data with:
rcmail::get_instance()->user->save_prefs(array('key' => $value));
or is there a way to save the data right where the identity is saved?
This is up to the plugin developer... either you use user prefs or you extend the identities database table. With the latter option you can copy the submitted data right into the 'record' property of the 'identity_update' hook and they'll be stored with the identities record.
Since Roundcube doesn't (yet) provide an install routine or script for plugins, you have to mention the schema changes in a README file and hope that people read it :-)
Regards, Thomas
Thank you for your help. Here is the next question:
How is the plugin supposed to now which identity was used to send an email? the smtp_connect hook doesn't provide the identity that was used to send a message nor does it provide an email address or message ID. I think there should be a message ID which invoked the smtp_connect hook that can be used to determine additional informations about the mail that is about to be sent. I hope you, or someone else, can help me.
Greetz elm
List info: http://lists.roundcube.net/dev/ BT/aba52c80
On Tue, Aug 16, 2011 at 20:18, Florian Mutter elm@skweez.net wrote:
How is the plugin supposed to now which identity was used to send an email? the smtp_connect hook doesn't provide the identity that was used to send a message nor does it provide an email address or message ID. I think there should be a message ID which invoked the smtp_connect hook that can be used to determine additional informations about the mail that is about to be sent. I hope you, or someone else, can help me.
The message ID is rather useless because there's no place to fetch additional information. The message is not yet stored in the IMAP backend, this is done after the mail was successfully delivered through smtp. I recommend to register another hook 'message_outgoing_headers' in your plugin in order to gather information about the message to be sent. The data passed to this hook also contains the From address which is set by the identity. Read the sender from there, store it in a member var of your plugin class and read it afterwards when smtp_connect is triggered.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80