Site icon

Add a Confirm Unsubscribe Link in Sendy

The newest version of Sendy has this feature built in. This edit is no longer needed.

This is as much for me to remember what in the heck I did so i can redo it the next time Sendy gets updated and I couldn't find anything online that told how to do this. I've learned over the years of helping people that others are probably looking for this too, so I'm putting it online instead of in OneNote.

The problem: I didn't like that clicking the Unsubscribe link in emails generated by Sendy immediately unsubscribed the address. I wanted a 'are you sure?' page to confirm because any antivirus or proxy scanner that verifies link will unsubscribe the address. IMHO, the is a shortcoming in the software and is a feature that should be built into it. (Another shortcoming is not recording IP Address used to subscribe - this is a must in any newsletter software but that will be another post.)

While I could set it up to send a good-bye email when someone signed off, if the proxy unsubscribes a person frequently, the subscriber will get tired of resubscribing.

First I had to find the file that had the code that unsubscribed the person from the list and make a copy. This would be unsubscribe.php (DOH!). I used the top part of the unsubscribe code (down to line 79) in file that has the unsubscribe button.

At the end of the file, I added a form with a button to click to unsubscribe. When the button is clicked, the original unsubscribe page loads and the user is unsubscribed. There is an else statement to load the original unsubscribe page should something go wrong.

Step 1:
At around line 46, add $unsublink = $_GET['i'];. This gets the variable that is passed in the unsubscribe link. If anything

  $time = time();  
  $feedback = '';
  $unsublink = $_GET['i'];
  //get variable

Step 2:

Next find else if(isset($_POST['email'])). Delete it and everything to the end. Replace it with the following code.

As seen in the screenshot above, after making these changes, the page displays the decoded email address in the button. When the button is clicked, the new link to unsubscribe is called and the address is removed from the list.

If if(isset($_GET['i'])) is not true, the new unsub link is called and processed.

Rename the original version unsub.php and the copy to unsubscribe.php and it's ready for testing.

  <div style="margin: 0px auto;width:400px;margin-top:100px"> 
  <p>Do you want to unsubscribe this address?</p> 
  <?php echo strtolower($email); ?> 
  <p> </p> 
  <form action="<?php echo $unsublink;?>" method="POST" accept-charset="utf-8"> 
  <input type="submit" name="submit" id="submit" value="Yes, unsubscribe <?php echo strtolower($email); ?>"/> 
    else { echo("<?php echo $unsublink;?>"); 

My finished unsubscribe file in here: unsubscribe php. You can use it - just don't forget to change the domain.

To use{unsubscribe code} as the link, you'll need to update the URL rewrites in the .htaccess file. (IIS users will update the web.config file... yes, Sendy works just fine on IIS.)

Exit mobile version