Yup, what he said is what you want.

    So would this work if I want a different mailing list per user...for example:

    Kate signs up for johndoe's blog mailing list.
    John signs up for iloveapples' blog mailing list.

    Can I keep track of this with the latter method?

      Yes, you can, just a bit of DB editing required. I'll post back later on tonite; if I don't remember to post back, make a "generic" post to this thread so it e-mail alerts me (otherwise I might forget 😃)

        Let me explain myself a bit more before you reply, disregard everything else you've read until now:

        I want to add a simple mailing list addition to a small blog site I run for a few friends of mine. Everyone at my site has their own username and can modify their blogs online. Now I want to add a mailing list feature for each user at my site, where anybody can register for the specific user's mailing list at their blog site.

        Let me first explain the simple structure of my database.

        I have tables called USERS, BLOG, and VISUAL. In USERS: I store username, password, location, etc. In BLOG: I store blog entries, dates updates, etc. In VISUAL: I store template names, colors, etc.

        Now, when somebody signs up for the mailing list for user 'johndoe', I will add their e-mail address to the database in a column called 'mailing_list'.

        That shouldn't be difficult when one person signs up, however, when multiple users sign up...how do I take care of multiple e-mails in one column? Are they separated by commas? line breaks? How does it work? How do I store them in an organized manner?

        Calling the e-mails is easy, simply:

        SELECT mailing_list FROM users WHERE username='johndoe';
        

        Thanks!
        -influx

          You're going to want to change your DB around a bit...here's what I'd do:

          Make a new table called "list" (or "mailing_list", or "lists"; I'll use "list" for this purpose). In it are a few fields: id (int, auto_increment, primary_key); uid (int); username (varchar [150]). Now, when someone "signs up" for a mailing list, this is what you do: you take the person who is signing up (the "signer") and get their unique ID number from the "users" table. Now, get the username of the blog who the person is signing up to (the "signee"), also from the "users" table. Now, insert both values - the ID of the signer and the username of the signee - into the "list" table, with "uid" being the ID, and "username" being the username. Now, users can sign up for more than one mailing list, and you can easily see how many users are signed up for a particular mailing list with a simple SQL query: "SELECT * FROM list WHERE username='johndoe'". The reverse can be done, finding out how many (and what) mailing lists a specific user has signed up for.

          This is called a "one-to-many" relationship, and in the database field, this method of breaking up tables like this is called "normalization". It's a lot more effecient, and mimics real life more accurately.

          Hope this helps!

            5 days later

            Sounds good, I just made the database addition and was just wondering: What happens when somebody inputs an incorrect e-mail address?

            When the user sends out a mass e-mail to the mailing list, and some of the addresses are incorrect, do I receive all the DELIVERY FAILURE e-mails at my admin e-mail account? Is there any way to ignore/avoid receiving the DELIVERY FAILURE emails?

            thanks,
            influx

              Test that the email is valid...

              if (ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $address))
              {
                  echo 'Invalid email address. Please enter a valid one';
              }
              

              $address is your email form variable ($address = $_POST['email_address'])

              Hope this helps.

                But that only checks if the format is valid, but somebody can input thisisfake@faker.com and it would still accept.

                I mean when I actually want to send out the e-mails, and I send an e-mail to what appears to be valid but is nonexistent, is there any way to not receive a DELIVERY FAILURE email in return?

                  Sometimes the mailer-daemon running at your STMP server will, after trying to initiate contact with the other SMTP server for too long, give you a message saying the e-mail failed to deliver.

                    So is there any way to tell it not to bother checking and not e-mail me to tell me? If it fails, it fails..I just don't want to hear about it.

                      Unless it's your own SMTP server, there's no way...if it is your own, you'll have to look in the manual, since I don't work with SMTP servers much.

                        It is my own SMTP server =)

                        How can I not receive emails that don't get to there destination and 'bounce back'?

                          Unfortunately, like I said, I don't handle configuration of SMTP server's other than the initial set-up. I have no idea how to do the more advanced features. Perhaps the other members here can lend a hand?

                            Write a Reply...