I have an API that saves email data to display the outgoing email on the site, I have made this code
// test data
$subject = "Test Subject";
$body = "Test Body";
$from_email = "
[email protected]";
$api_data = [
"subject" => $subject,
"body" => $body,
"from_email" => $from_email
];
// send data to API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://myapi/api/receive-email");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($api_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
unlink($cache_file);
echo "HTTP Code: $http_code\n";
echo "Response: $response\n";
how to pass email data from roundcube to API?
have a look at the message_before_send (https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#message_before_send) or the message_sent (https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#message_sent) plugin hooks
Quote from: JohnDoh on March 06, 2025, 02:45:05 AMhave a look at the message_before_send (https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#message_before_send) or the message_sent (https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#message_sent) plugin hooks
I found how to create my custom hook, but in which directory to create it? /usr/share/roundcube/plugins?
Here are the basics of creating a plugin: https://github.com/roundcube/roundcubemail/wiki/Plugin-API