title: Enabling the PHP Mail() Function in Parallels Plesk
body: <p>I am trying to get some PHP scripts to use the PHP Mail function on my site using our 1and1 mail server credentials.</p>
  
  <p>I am running Parallel Plesk on a Windows Server.</p>
  
  <p>From logging into plesk and checking the specific site I can see I am running PHP 5.4</p>
  
  <p>After following this link </p>
  
  <p><a href="https://support.plesk.com/hc/en-us/articles/213411789-PHP-mail-function-does-not-work" rel="nofollow noreferrer">Setup PHP.ini with Plesk</a></p>
  
  <p>I have gone to;</p>
  
  <blockquote>
    <p>C:\Program Files (x86)\Paralells\Plesk\Additional\PleskPHP54\php.ini</p>
  </blockquote>
  
  <p>and ammended to the following;</p>
  
  <pre><code>SMTP = auth.smtp.1and1.co.uk
  smtp_port = 587
  auth_username = username
  auth_password = password
  sendmail_from = myemail
  </code></pre>
  
  <p>The PHP Script being used is as follows;</p>
  
  <pre><code>&lt;?php
      $method =  $_SERVER["REQUEST_METHOD"];
      if ($method == "POST") {
          $name = strip_tags(trim($_POST["name"]));
          $name = str_replace(array("\r","\n"),array(" "," "),$name);
          $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
          $recipient = "test@myemail.com";
          $subject = $_POST["subject"];
          $email_content = "Name: $name\n";
          $email_content .= "Email: $email\n\n";
          $email_content .= "Message:\n$message\n";
          $email_content = str_replace("\n.", "\n..", $email_content);
          $email_headers = "From: $name &lt;$email&gt;";
          //mail($recipient, $subject, $email_content);
          if (mail($recipient, $subject, $email_content, $email_headers)) {
              http_response_code(200);
              echo "Thank You! Your message has been sent.";
          } else {
              http_response_code(500);
              echo "Oops! Something went wrong and we couldn't send your message.";
          }
      } else {
          http_response_code(403);
          echo "There was a problem with your submission, please try again.";
      }
  ?&gt;
  </code></pre>
  
  <p>a 500 Error is always returned at this point. can anyone direct me as to what I am doing wrong here?</p>
  
  <p>As an update if I go to</p>
  
  <p>Tools &amp; Settings -> Mail Server Settings</p>
  
  <p>I can see Mail Enable is installed and running (if I go to Webmail i can see this is version 9).</p>
  
  <p>I have also then tried going to the following</p>
  
  <p>Tools &amp; Settings -> External SMTP Server Settings</p>
  
  <p>and unchecking the Use the mail server installed with Plesk and the default mail account created by Plesk option and completing this. </p>
  
  <p>However, its still not working?</p>