title: How to pass javascript processed data over to PHPmailer? Do I need to run a mail server on my comptuer (win 7)?
body: <p>So essentially I get a string out of javascript of the warmest cities in the world right now by making use of the weather API. but then I want to take that STRING and pass it through to mail.php to be mailed to myself. </p>
  
  <pre><code>        httpRequest = new XMLHttpRequest();
  
          httpRequest.open("GET", api, false);
  
          httpRequest.send();
  
          var returned = JSON.parse(httpRequest.responseText);
  
          var string = "";
  
          for(var i = 0; i &lt; returned.items.length; i++){
              console.log(returned.items[i].link);
  
              string += returned.items[i].link + ", " +  "\n";
  
  
          }
          console.log("HellO");
          console.log(string)
  
  
  function post(path, params, method) {
  method = method || "post"; // Set method to post by default if not specified.
  
  // The rest of this code assumes you are not using a library.
  // It can be made less wordy if you use one.
  var form = document.createElement("form");
  form.setAttribute("method", method);
  form.setAttribute("action", path);
  
  for(var key in params) {
      if(params.hasOwnProperty(key)) {
          var hiddenField = document.createElement("input");
          hiddenField.setAttribute("type", "hidden");
          hiddenField.setAttribute("name", key);
          hiddenField.setAttribute("value", params[key]);
  
          form.appendChild(hiddenField);
      }
  }
  
  document.body.appendChild(form);
  form.submit();
  
  post(mail.php, string, POST)
  </code></pre>
  
  <p>and then on my mail.php I Have </p>
  
  <pre><code>use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\Exception;
  
  require './PHPMailer/src/Exception.php';
  require './PHPMailer/src/PHPMailer.php';
  require './PHPMailer/src/SMTP.php';
  
  $mail = new PHPMailer;
  
  $mail-&gt;isSMTP();                                      // Set mailer to use     
  SMTP
  $mail-&gt;Host = 'smtp.gmail.com';                       // Specify main and 
  backup server
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP 
  authentication
  $mail-&gt;Username = 'email@email.com';                   // SMTP username
  $mail-&gt;Password = 'password';               // SMTP password
  $mail-&gt;SMTPSecure = 'tls';                            // Enable encryption, 
  'ssl' also accepted
  $mail-&gt;Port = 587;                                    //Set the SMTP port 
  number - 587 for authenticated TLS
  $mail-&gt;setFrom('email@email.com', 'Amit Agarwal');     //Set who the message 
   is to be sent from
  $mail-&gt;addReplyTo('labnol@gmail.com', 'First Last');  //Set an alternative 
  reply-to address
  $mail-&gt;addAddress('josh@example.net', 'Josh Adams');  // Add a recipient
  $mail-&gt;addAddress('ellen@example.com');               // Name is optional
  $mail-&gt;addCC('cc@example.com');
  $mail-&gt;addBCC('bcc@example.com');
  $mail-&gt;WordWrap = 50;                                 // Set word wrap to 50 
  characters
  // $mail-&gt;addAttachment('/usr/labnol/file.doc');         // Add attachments
  // $mail-&gt;addAttachment('/images/image.jpg', 'new.jpg'); // Optional name
  $mail-&gt;isHTML(true);                                  // Set email format to 
  HTML
  
  $mail-&gt;Subject = 'Here is the subject';
  $mail-&gt;Body    = POST['string'];
  $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
  //Read an HTML message body from an external file, convert referenced images 
  to embedded,
  //convert HTML into a basic plain-text alternative body
  $mail-&gt;msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  
  if(!$mail-&gt;send()) {
     echo 'Message could not be sent.';
      echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
     exit;
  }
  
  echo 'Message has been sent';
  </code></pre>
  
  <p>but yet no matter what happens that email doesn't send. In order to send a php email do I need a mail server open on my windows 7 box, do i need a php.ini file (if so what for), and am I sending the mail out wrong. </p>
  
  <p>Im going javscript > Weather API > JAVASCRIPT > STRING > EMAIL </p>
  
  <p>yet its not sending.</p>
  
  <p>I've been trying for a while now and I just can't figure out what exactly Im missing. </p>