Unsubscribe and Blacklist

Even though you are not sending emails yourself (it's done by the server script from that contact form), you still might want to use the following PHP-script on your website to collect domains of sites where you have sent a message but who are not interested. This would prevent any further problems and not send there again. Instructions are also in the script for further details.



  1. Upload this file to your webserver and call it e.g. unsubscribe.php
  2. In GSA Website Contact -> Edit Project ->Submission Content->Message add something like...

    Click the following link to unsubscribe: http://www.mywebsite.com/unsubscribe.php?d=%domain%
  3. in GSA Website Contact -> Options -> Global Filter -> add the URL to your $blacklist_filename from below


    $blacklist_filename="blacklist.txt";  //the filename where it is stored and where the program can access it to read unsubscribed data
    //a message given to the user
    $message_title="Successfully unsubscribed"; 
    $message_body="We apologize for any inconvenience. We will no longer contact you in the future.";
    $message_redirect_url=""; //if set, it will go to this URL after a short time
//------------------ the code starts below -------------

    //check if a special GET parameter is present, if not, set it via javascript and reload
    //this prevents that bots will crawl this URL and add domains to the blacklist
    if((!isset($_GET['real']) || ($_GET['real']!="yes")) {
      echo "<script>let url=window.location.href;if(url.indexOf('?')>-1){url+='&real=yes'} else {url+='?real=yes'};window.location.href=url;</script";
    } else {
      //get domain and validate
      if(($domain!="") && (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/',$domain))) {
        file_put_contents($blacklist_filename, $domain."\n",FILE_APPEND);
    //output some message
    echo "<html>\n".
         "  <head>\n".
         "    <title>".$message_title."</title>\n".
         '    <meta charset="utf-8">'."\n".
         '    <meta name="viewport" content="width=device-width,initial-scale=1">'."\n".    
         "    <style>\n".
         "      *{margin:0; padding:0; box-sizing:border-box;--textcolor:#fff;  --bgcolor:#121212;  --highlight:#2749c9;}\n".
         "      @media (prefers-color-scheme:dark){*{--textcolor:#141414;    --bgcolor:#f0f0f0;    --highlight:#ff7f00;}}\n".
         "      body{font-size:18px;  font-family:system-ui,sans-serif;  line-height:1.4;  color:var(--textcolor);  background:var(--bgcolor);  position:relative;  max-width:64em; margin:0 auto;}\n".
         "      header{padding:5vw 5vw 0 5vw; display:flex; flex-wrap:wrap; position:absolute; width:100%; z-index:2;}\n".
         "      header h1{font-size:1em;  flex:1;white-space:nowrap; padding:0 5vw .5em 0;}\n".
         "      p,ul,ol,article{max-width:60ch;margin-bottom:.6em;}\n".
         "    </style>\n";

    if($message_redirect_url!="") echo '    <meta http-equiv="refresh" content="5;url='.$message_redirect_url.'" />'."\n";
    echo "  </head>\n".
         "  <body>\n".
         "    <br><br><h1>".$message_title."</h1>\n".
         "    <br><p>".$message_body."</p>\n".
         "  </body>\n".