title: Why isn't this PHP-script sending the email?
body: <p>I'm trying to get a contact form on a web page to work after the web host stopped supporting the PHP-version it was built for. For some reason I can't get the email to send and I can't for the life of me figure out whats wrong with the code!</p>
  
  <p>Using Chrome to monitor the network traffic I get the error message that is added to the block below.</p>
  
  <p><code>{success: false, error: "Kunde inte skicka e-postmeddelande"}</code>
  ("Unable to send email")</p>
  
  <p>Here is the block that send the email:</p>
  
  <pre><code>$to = $form['email']['to'];
      $subject = $form['subject'];
      $message = get_email_body($subject, $form['heading'], $form['fields'], $form['resources']);
      $headers = get_email_headers($to, $form_email); 
  
      $sent = @mail($to, $subject, $message, $headers);
  
      if(!$sent)
          die(get_form_error_response($form['resources']['failed_to_send_email']));
  
      $success_data = array(
          'redirect' =&gt; $form['success_redirect']
      );
  </code></pre>
  
  <p>Since I can't find any errors in the code I'm stuck. If anyone can see anything I can't, or maybe point me to where to look next I'd be eternally grateful! </p>