Hello,
I made a small piece of code that i think could help out others with a similar issue.
I have about hundred servers that is sending welcome emails out themself instead of having WHMCS to do it. That was annoying since i couldn't resend old emails, so i decided to use the WHMCS API to send emails. But i quickly ran into an issue - i had to add every single server IP on the API allow list. As i couldn't find an option to disable this allow list, i had to figure something else out. I ended up with writing a small PHP script that acts as a proxy to the API, so i only would have to whitelist the IP of the webserver. Simply copy/paste the following code into whmcs/includes/localapi.php (actually localapi.php can be called anything), and then use that file instead of api.php:
<?php
$ch = curl_init();
$url = str_replace('/'.basename(__FILE__),'/api.php',$_SERVER['REQUEST_URI']);
if (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']=='on') {
curl_setopt($ch, CURLOPT_URL, 'https://'.$_SERVER['HTTP_HOST'].$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
} else {
curl_setopt($ch, CURLOPT_URL, 'http://'.$_SERVER['HTTP_HOST'].$url);
}
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
}
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// Lighttpd doesn't support the Expect header.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_exec($ch);
?>
Best regards,
Niklas