I am trying to send an email using the built-in Kirby function, but it fails.
The E-Mail will be send, though as in it arrives in my mailbox, but the validation still fails…?
I understand that. But the point is that one suggestion is to change the location of the log file in php.ini (and create that file location somewhere, where you have access and permissions to).
Anyhow, this is nothing Kirby can fix, because it is a permission problem. If you can’t find a solution, you may want to contact your provider. Or use PHPMailer, or an external service.
I just tried something along your input:
when I create a single file (not within Kirby), it works without problems; the mail is send, no error appears.
I am just using plain PHP mail() function.
Using the same within Kirby, fails with
Whoops \ Exception \ ErrorException (E_WARNING)
mail(/var/log/phpmail.log): failed to open stream: Permission denied
I saw that Kirby uses the normal PHP function, that is why I am confused as to why this happens.
I altered the code to be the following. Mail is send, but error is also echoed:
$email = email(array(
'to' => 'to@example.com',
'from' => 'my@email.com',
'subject' => 'Sending emails with Kirby is easy',
'body' => 'Hey! This was really easy!'
));
if($email->send()) {
echo 'The email has been sent';
} else {
echo $email->error();
}
Output is:
Warning: mail(/var/log/phpmail.log): failed to open stream: Permission denied in /home/www-data/example.com/docs/kirby/vendor/getkirby/toolkit/lib/email.php on line 159
The email has been sent
So to me it is not a permissions problem, but a Kirby problem? - even though I can’t find any references to phpmail.log or why exactly the log has to be written (or what is even in it!)
Backtracking within the Whoops Vendor did not help - or at least I don’t know where to look at
As I said above, the mail log is nothing that is generated by Kirby. I think if you uncomment the log line in php.ini, no log should be created at all. This seems to be a PHP configuration thing.