Advertisement
shumilica

sendy mail notification new subscribers php

Aug 27th, 2014
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     //------------------- Edit here --------------------//
  3.     $sendy_url = 'http://your.sendy.installation';
  4.     $list = $_POST['list'];
  5.     //------------------ /Edit here --------------------//
  6.  
  7.     //--------------------------------------------------//
  8.     //POST variables
  9.     $name = $_POST['name'];
  10.     $email = $_POST['email'];
  11. //url2 is used not let spammers subscribe by putting a hidden field in the form.
  12.     $url2 = $_POST['url2'];
  13. //put here any other custom fields you have in the same way as url2 or email or name. Make sure the name in the [''] matches the id of the input field from the html and js file
  14.  
  15.  
  16. //if url2 is completed, don't subscribe (but it gives a success message to the bot (in the .js script)
  17.     if($url2) {
  18.     echo "bleah";
  19.      }
  20.     else {
  21.       //subscribe, put here all the other custom fields. I didn't put url2 because it's only used in this php to check if it's filled
  22.     $postdata = http_build_query(
  23.         array(
  24.         'name' => $name,
  25.         'email' => $email,
  26.         'list' => $list,
  27.         'boolean' => 'true'
  28.         )
  29.     );
  30.     $opts = array('http' => array('method'  => 'POST', 'header'  => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
  31.     $context  = stream_context_create($opts);
  32.     $result = file_get_contents($sendy_url.'/subscribe', false, $context);
  33.  
  34.     echo $result;
  35.  
  36. //you can erase this part if you only want to check for spammers but not send an email notification
  37. if($result == "1") {
  38. //you can add more custom fields with the . (dot) function.
  39. mail('email.address.to.send.the.notification@yourmail.com', 'Subject of the email', $message.$name."\n".$email); }
  40. //erase until here if you don't want to send mail notification
  41.     };
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement