0

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

gerhard
  • 479
  • 1
  • 6
  • 15
  • Are you running your code on a live server or local server ? – Sinf Nov 02 '16 at 11:34
  • code is running on a live server – gerhard Nov 02 '16 at 11:50
  • @John: the question you are referring to as a duplicate is a quite general one, whereas my question is very specific: the provided code runs for email addresses for mydomain, but not for other email addresses. – gerhard Nov 02 '16 at 13:52
  • Which indicates something outside of your code is preventing it from being received. That canonical question covers all of that. – John Conde Nov 02 '16 at 14:01

0 Answers0