Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: himari_usagi on January 13, 2023, 06:25:58 AM

Title: How to send email from JavaScript code, in a plugin
Post by: himari_usagi on January 13, 2023, 06:25:58 AM
Hi,

I have a plugin that must add a disclaimer to a composed email, just before sending.
The email-altering code must use JavaScript, and so is triggered by a 'beforesend' event handler.

The disclaimer is obtained via an async HTTP call, which means:
1. the 'beforesend' handler must return false, to prevent the immediate email send, and give time to the HTTP call to happen;
2. after the disclaimer is obtained and the composed email altered, an email "send" action must be triggered.

My question is how to trigger an email send using JavaScript.

Thanks
Title: Re: How to send email from JavaScript code, in a plugin
Post by: JohnDoh on January 14, 2023, 03:32:28 AM
call the action like this
Code: [Select]
rcmail.command('send','')
or call the send function directly like this:
Code: [Select]
rcmail.submit_messageform()