The following PHP-code works perfectly for recipients on the same domain, however fails for email-addresses from other domains:
$app->post('/request_password', function() use ($app) {
$response = array();
$recipient= $app->request->post('email'); // reading post params
$new_password = generateRandomString7();
...
$subject= 'Your new password';
$message= 'Your new password is: ' . $new_password;
$header = 'From: service@mydomain.at' . "\r\n" .
'Reply-To: noreply@mydomain.at' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($recipient, $subject, $message, $header))
$response["error"] = false;
$response["message"] = "Mail sent successfully";
echoRespnse(201, $response);
} else {
$response["error"] = true;
$response["message"] = "Failed to send mail";
echoRespnse(203, $response);
}
});
In both cases (receiver on mydomain / receiver on any other domain) the script finishes successfully. Only if the recipient is an email-address on mydomain the email appears in the in-box, other-domain-recipients do never receive the email.
Any idea what could be wrong? Do you need any additional information?
Thanks! Gerhard