title: PHP: How to modify working email script to run on own server (PHP mail server setup on LAMP server)
body: <p>I am using lines like the below to send emails after submitting a form on my website.<br>
  So far everyhing works as intended.  </p>
  
  <p>Now I would like to set up my own server and would like to avoid setting up an email client on this server.<br>
  <strong>Can someone tell me what I have to add here to set this up to use a mailing server ?</strong><br>
  Does this work using IP addresses or do I need an extra PHP file for this kind of set up ? </p>
  
  <p><strong>Note:</strong> My emails will only contain text and some basic HTML, no attachments. </p>
  
  <p>I am pretty new to PHP and was hoping to get some help in getting started with this here. </p>
  
  <p><strong>My PHP (shortened):</strong>  </p>
  
  <pre><code>// get submitted form data
  $postData = $_POST;
  // retrieve some post data to include in email
  
  unset($postData);
  
  // prepare email
  $to = 'someone@mail.com';   
  $subject = 'Some text';
  
  $emailBody = '&lt;html&gt;&lt;body&gt;Some HTML text&lt;/body&gt;&lt;/html&gt;';    
  $headers = 'From: Someone &lt;someone@mail.com&gt;' . PHP_EOL .
      'Cc: someoneelse@mail.com &lt;someoneelse@mail.com&gt;' . PHP_EOL .
      'Reply-To: noreply@mail.com &lt;noreply@mail.com&gt;' . PHP_EOL .
      'X-Mailer: PHP/' . phpversion();                                
  
  // set content-type header for sending HTML email
  $headers .= "\r\n". "MIME-Version: 1.0";
  $headers .= "\r\n". "Content-type:text/html;charset=UTF-8";
  
  // send email
  $mail = mail($to, $subject, $emailBody, $headers);
  
  if($mail) {
      header('Location: support.php?status=emailSent');
  }
  </code></pre>
  
  <p>Many thanks in advance, 
  Tom</p>