Hi all!
It seems, that at least the error cause is found: after talking to the df.eu support, the reason seems to be, that Domainfactory changed their general server configuration and now they are forcing a ReturnPath with the parameter -f within the sendmail_path in the php.ini (which I cannot access). Kirby seems to force a ReturnPatch with phpmailer by its´ own, which causes an error. The suggested solution should be to add the parameter 0 to phpmailer.
$mail->setFrom('absender@domain.tld', 'Mailer' ,0);
But I absolutely do not know where to integrate that in the system and I found no documentation. Alternatively, I tried to integrate this within my script of the control contact.php, but it does not work:
$kirby->email([
'beforeSend' => function ($mailer) {
$mailer->setFrom('info@domain.de', esc($data['name']) ,0);
return $mailer;
}
]);
I am not sure, where to integrate that correctly, here is my complete code, whichs throws the error " Undefined variable: data". I think after 2 days staring at this piece of code, I am getting blind, a coffe and a cake for the one who solves this:
<?php
return function($kirby, $pages, $page) {
$alert = null;
if($kirby->request()->is('POST') && get('submit')) {
// check the honeypot
if(empty(get('website')) === false) {
go($page->url());
exit;
}
$data = [
'name' => get('name'),
'email' => get('email'),
'text' => get('text'),
'optin' => get('optin')
];
$rules = [
'name' => ['required', 'minLength' => 1],
'email' => ['required', 'email'],
'text' => ['required', 'minLength' => 1, 'maxLength' => 3000],
'optin' => array('required')
];
$messages = [
'name' => 'Please enter a valid name',
'email' => 'Please enter a valid email address',
'text' => 'Please enter a text between 3 and 3000 characters',
'optin' => 'Bitte markieren Sie die Checkbox, um uns zu erlauben Sie zu kontaktieren.'
];
// some of the data is invalid
if($invalid = invalid($data, $rules, $messages)) {
$alert = $invalid;
// the data is fine, let's send the email
} else {
try {
$kirby->email([
'beforeSend' => function ($mailer) {
$mailer->setFrom('info@domain.de', esc($data['name']) ,0);
return $mailer;
},
'template' => 'email',
'from' => 'info@domain.de',
'replyTo' => $data['email'],
'to' => 'info@domain.de',
'subject' => esc($data['name']) . ' hat Ihnen eine Nachricht über Ihr Kontaktformular geschickt',
'data' => [
'text' => esc($data['text']),
'sender' => esc($data['name']),
'email' => esc($data['email'])
]
]);
} catch (Exception $error) {
if(option('debug')):
$alert['error'] = 'Ihre Nachricht konnte leider nicht verschickt werden <strong>' . $error->getMessage() . '</strong>';
else:
$alert['error'] = 'Da ist leider etwas schiefgelaufen!';
endif;
}
// no exception occurred, let's send a success message
if (empty($alert) === true) {
$success = 'Ihre Nachricht wurde erfolgreich versandt! Wir melden uns so schnell wie möglich bei Ihnen.';
$data = [];
}
}
}
return [
'alert' => $alert,
'data' => $data ?? false,
'success' => $success ?? false
];
};
Thanks a million!!