Menu

Automatic subscription to newsletters

2000-09-11
2000-09-12
  • Daniel Adad

    Daniel Adad - 2000-09-11

    Hi folks,

    I've added an automatic option to let people that register as users to sign up to our newsletter automatically, just replying to the password confirmation message. You should have an automatic subscription email address, such as you can find at egroups.com or topica.com.

    Add these lines to config.php3:

    -----------START----------------------

    ##########################################
    # Autosubscription to mailing list       #
    ##########################################

    $subscribe= "1";    # "1" to automatically subscribe upon replying to password message
                # "0" to skip subscription to mailing list
    $replytosubscribe = "put-here-your-autosubscription-email@newsletter.com";    #Address to reply-to and automatically subscribe to mailing list (leave blank if no automatic subscription)

    ----------- END ----------------------

    Then, change function finishNewUser in user.php3 as follows. Find where it says:

    -----------------------
            if(!$result) {
                echo mysql_errno(). ": ".mysql_error(). "<br>";
            } else {
                $message = "".translate("Welcome to")." $sitename!\n\n".translate("You or someone else has used your email account")." ($email) ".translate("to register an account at")." $sitename. ".translate("The following is the member information:")."\n\n".translate("-Nickname: ")." $uname\n".translate("-Password: ")." $makepass";
                $subject="".translate("User Password for")." $uname";
                $from="$adminmail";
                if ($system == 1) {
                    echo "".translate("Your password is: ")."<b>$makepass</b><br>";
                    echo "<a href=\"user.php3?op=login&uname=$uname&pass=$makepass\">Login</a> to change your info";
                } else {
                    mail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());
                    echo "".translate("You are now registered. You should receive your password at the email account you provided.")."";
                }
    ------------------------

    and change it for:

    ------------------------
            if(!$result) {
                echo mysql_errno(). ": ".mysql_error(). "<br>";
            } else {
                $message = "".translate("Welcome to")." $sitename!\n\n".translate("You or someone else has used your email account")." ($email) ".translate("to register an account at")." $sitename. ".translate("The following is the member information:")."\n\n".translate("-Nickname: ")." $uname\n".translate("-Password: ")." $makepass";
                $subject="".translate("User Password for")." $uname";
                if ($subscribe) {$message = $message . "\n\n".translate("To complete your subscription, reply to this message and send it.");}
                $from="$adminmail";
                if ($subscribe) {$replysubscribe="Reply-To: $replytosubscribe\n";}
                else {$replysubscribe="";}
                if ($system == 1) {
                    echo "".translate("Your password is: ")."<b>$makepass</b><br>";
                    echo "<a href=\"user.php3?op=login&uname=$uname&pass=$makepass\">Login</a> to change your info";
                } else {
                    mail($email, $subject, $message, "From: $from\n".$replysubscribe."X-Mailer: PHP/" . phpversion());
                    echo "".translate("You are now registered. You should receive your password at the email account you provided.")."";
                }
    ------------------------

    You should also add an entry:

    "You are now registered. You should receive your password at the email account you provided."

    in your language files, and the corresponding translation too, of course.

    HTH, and keep up with the good work. Tell me if you need further help on this. I think it's quite simple, but it helps a lot, it's powerful.

    Regards,
    Dany

     
    • Kelly Hamlin

      Kelly Hamlin - 2000-09-12

      Excellent! People like this are gonna make this project fly!
      Im adding this to the Code for PHP-Bomb Release 1.
      Credits will be appended for this feature.

       
      • Kelly Hamlin

        Kelly Hamlin - 2000-09-12

        Also, im gonna try to add to this where you can mail the newsletter from the admin section of site.

         

Log in to post a comment.

MongoDB Logo MongoDB