title: How does Mail PHP work?
body: <p>I stumbled on the following script today for sending an e-mail using PHPMail.</p>
  
  <pre><code>&lt;?php
      $to = "some_address@domain.com";
      $subject = "Test mail";
      $message = "Hello! This is a simple email message.";
      $from = "my_address@domain.com";
      $headers = "From:" . $from;
      mail($to, $subject, $message, $headers);
      echo "Mail Sent.";
  ?&gt;
  </code></pre>
  
  <p>Above can be runnable through <code>php mail.php</code> and instantly you'll get an e-mail sent to <code>$to</code> from <code>$from</code> despite not needing to set outgoing/ingoing servers out.</p>
  
  <p>It really intrigued me, since my CMS uses an SMTP outgoing server (well, same way Mail PHP does), which I need to set up with my Outlook SMTP username and password - some sort of verification.</p>
  
  <p>However, about Mail PHP just.. sends an e-mail. To the address you set it as. From the address you set it as.</p>
  
  <p>Looking at <a href="http://php.net/manual/en/function.mail.php" rel="nofollow noreferrer">PHP docs</a> it does not really reveal how it works. Does Mail PHP not have any issues with spamming since anyone can send anyone anything anytime programmatically without verification of the <code>from</code> identity?</p>
  
  <p>EDIT:</p>
  
  <p>It's rather funny the people in the comments were talking about the POTUS, since I had the exact thing in mind:</p>
  
  <p><img src="https://i.stack.imgur.com/ajehP.png" alt="enter image description here"></p>
  
  <p>It <em>did</em> land in my junk folder, but I'm sure it isn't hard to make this look convincing enough and still be considered <code>"oh damn spam filter lost my e-mail!"</code></p>