Nextcloud version: 29.0.5
Operating system: Shared host Linux
Apache version: 2.4
PHP version: 8.2
The issue you are facing:
After updating Nextcloud from version 28 to 29, I am facing with the error 503 when using url ocs/v1.php/cloud/users/{userid}/welcome with curl command from a SSH terminal and php-cli 8.2.
On the other hand, the email is correctly sent if I use the option ‘send welcome mail’ from the web interface using the same user (administrator).
This has been working fine until NC 28.
Steps to replicate it:
- Create a PHP script (let’s call it ‘mailsender.php’) similar to:
<?php
$username = 'michael';
$options[CURLOPT_URL] = 'https://mydomain/nextcloud/ocs/v1.php/cloud/users/' . urlencode($username) . '/welcome';
$options[CURLOPT_PORT] = 443;
$options[CURLOPT_USERPWD] = $oc_user . ':' . $oc_pass;
$options[CURLOPT_FRESH_CONNECT] = true;
$options[CURLOPT_FOLLOWLOCATION] = true;
$options[CURLOPT_FAILONERROR] = true;
$options[CURLOPT_RETURNTRANSFER] = true;
$options[CURLOPT_TIMEOUT] = 15;
$options[CURLOPT_POST] = true;
$options[CURLOPT_HEADER] = true;
$options[CURLOPT_HTTPHEADER] = array("OCS-APIRequest: true");
$curl = curl_init();
curl_setopt_array($curl, $options);
if (curl_exec($curl) === false) {
echo "[Request ERROR] Welcome email sent to " . $username . " failed!: " . curl_error($curl) . PHP_EOL;
}
else {
echo "[Request OK] Sent welcome email to " . $username . PHP_EOL;
}
curl_close($curl);
?>
, where $oc_user and $oc_pass are the credentials for an admin user.
-
Upload the script to a folder in the same host of the NC installation.
-
Open a SSH shell and type:
/usr/bin/php8.2-cli /path_to_my_server/htdocs/mailsender.php
- Result:
[Request ERROR] Welcome email sent to michael failed!: The requested URL returned error: 503
Please, anyone can help?
Thanks in advance.