Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('../lib/phpmailer/class.phpmailer.php');
  4. require_once('../config.php');
  5.  
  6.  
  7. if (!empty($_POST['name']) && !empty($_POST['email']))
  8. {
  9.     $output_text = "Name : {$_POST['name']}\nEmail : {$_POST['email']}";
  10.    
  11.     $newmailer = new phpmailer();
  12.     $newmailer->IsSMTP();
  13.     $newmailer->Host = $config['smtp_host'];
  14.     $newmailer->SMTPAuth = true;
  15.     $newmailer->Username = $config['smtp_username'];
  16.     $newmailer->Password = $config['smtp_password'];
  17.     $newmailer->Port = $config['smtp_port'];
  18.     $newmailer->WordWrap = 70;
  19.    
  20.     $newmailer->Debug = 2;
  21.    
  22.     // configure the message
  23.    
  24.     $newmailer->From = $config['smtp_from'];
  25.     $newmailer->FromName = 'EpixHD';
  26.     $newmailer->AddAddress('freeforall@epixhd.com','freeforall');
  27.    
  28.     $newmailer->IsHTML(false);
  29.     $newmailer->Subject = "Free For All Newsletter Signup";
  30.     $newmailer->Body = $output_text;
  31.    
  32.    
  33.     if (!$newmailer->Send())
  34.     {
  35.         $response = array('success' => false, 'message' => 'Couldn\'t submit entry');
  36.     } else {
  37.         $response = array('success' => true,'message' => 'Thanks for signing up for the newsletter!');
  38.     }
  39.    
  40. } else {
  41.     $response = array('success' => false, 'message' => 'Please enter your name and a valid email address.');
  42. }
  43.  
  44. $handlers = ob_list_handlers();
  45. for ($cnt = 0; $cnt < sizeof($handlers); $cnt++) { ob_end_clean(); }
  46. header("Cache-Control: no-cache, must-revalidate");
  47. header('Content-Type:application/json');
  48. $length = strlen(json_encode($response));
  49. header('Content-Length:'.$length);
  50. echo json_encode($response);
  51. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement