+ Reply to Thread
Results 1 to 6 of 6

Thread: Mailing list implimentation.

  1. #1
    wjh2303 is offline x10 Sophmore wjh2303 is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    139

    Mailing list implimentation.

    Id like to set up a mailing list associated with my wbsite so i can inform subscribers of updates, but cant quite figure out how to do so. I got as far as createing an e-mail account and mailing list from cpanel.
    I had a search through google and such, but cant quite figure how to have a form on a page where people can put thir e-mail to subscribe. Could someone provide, either in text or by link, a quick guide on how to impliment a mailing list for a website.

    Hlp apprciated thanks.

  2. #2
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Mailing list implimentation.

    I could, as could many others here but first...

    Does your server support server-side scripting like php?

    Do you have a database set up?

    Do you do any coding or use WYSIWYG editors like Dreamweaver? (or nothing and use a content management system)

  3. #3
    wjh2303 is offline x10 Sophmore wjh2303 is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    139

    Re: Mailing list implimentation.

    Im just using the x10 free hosting, so php is supported, and mySQL databases, im already using both of them in the site. I use a plain text editor (notepad++) for the editing.

    thanks

  4. #4
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Mailing list implimentation.

    First off, you need to have a field in your contact/email database that specifies if they are a subscriber - usually a Y/N field (varchar (1)) or 0/1 (tinyint)

    Second, you need to create a page (preview.php) that you can use to design your e-mail - whether it be in plain text or more complex htm.

    This page will have a form, with two inputs - one for the Subject (text field) and one for the message (text area) and, of course a submit button.

    When you click on submit, the php code will post the data back to the same page and parse the contents - to give a good idea of what it will look like. (make sure this page has no css!)

    i.e.

    PHP Code:
    <?php

    echo stripslashes($_POST['subjectfield']);
    echo 
    stripslashes($_POST['messagefield']);

    ?>
    Personally, I put the contents of the post variables into session variables for ease of passing between one page and the next.

    PHP Code:
    <?php

    $_SESSION
    ['sesssubject'] = $_POST['subjectfield']
    $_SESSION['sessmessage'] = $_POST['messagefield']

    ?>
    If you put the default value of the form fields as the posted values, you can keep editing your input until you get the desired effect.

    Right at the bottom of the body, you then put in a standard link to the clever page.... (you don't need to post or pass the variables into the next page as they are in session memory)

    mail.php

    The first part of this page is a recordset (I'll call it subscriberlist), based on whether a contact has subscribed or not.

    sql.... SELECT ID, EMAIL, SUBSCRIBED FROM CONTACTS WHERE SUBSCRIBED ="Y"

    Then, what I do, is to echo the results so you can check your recipients.

    So... in the page body, created a repeating table

    PHP Code:
    <form>
    <table>
    <?php do { ?>
    <tr>
    <td>
    <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row_subscriberlist['ID']; ?>" />
    </td>
    <td><?php echo $row_subscriberlist['EMAIL'];?></td>
    <td><?php echo $row_subscriberlist['SUBSCRIBED'];?></td>
    </tr>
    <?php } while ($row_subscriberlist mysql_fetch_assoc($subscriberlist)); ?>
    </table>
    <input name="rowstosend" type="hidden" value="<?php echo $totalRows_subscriberlist;?>" />
    <input name="send" type="submit" id="send" value="Send E-mails" />
    </form>

    You'll note that I've wrapped a form tag round the whole table and entered a checkbox in the left table column with a weird name.

    You can either then manually input ticks for each subscriber, or get some javascript to fill them all in for you.

    I've also put in two field at the bottom - one of which carries a value for the number of rows in the recordset and the other is just a button to do the magic.

    Next is the code to send them...

    PHP Code:

    <?php
        
    // Check if edit button active, start this 
        
    if($send)
        {
        for(
    $i=0;$i<$_POST['rowstosend'];$i++)
            {
                
    $edit_id $checkbox[$i];
                if (isset(
    $edit_id))
                {
                    
    $query_sendlist sprintf("SELECT ID, EMAIL FROM CONTACTS WHERE ID LIKE '$edit_id'");
                    
    $sendlist mysql_query($query_sendlist) or die(mysql_error());
                    
    $row_sendlist mysql_fetch_assoc($sendlist);
                                    
                    
    $toemail stripslashes($row_sendlist['EMAIL']);
                    
                    
    $headers  'MIME-Version: 1.0' "\n";
                    
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\n";
                    
    $headers .= "Content-Transfer-Encoding: 7bit\n"
                    
    $headers .= 'From: yourname <'youremailaddress'>' "\n";
                    
    $headers .= 'Reply-To: 'youremailaddress"\n";
                    
    $headers .= 'X-Mailers: PHP /'.phpversion() . "\n";
                    
    $subject $_SESSION['sessionsubject'];
                    
    $message $_SESSION['sessionmessage'];
                    
    $message str_replace("<<<NAME>>>"$row_sendlist['NAME'], $message);
                            
                    
                    echo 
    "</br>Mailing: ".$row_sendlist['EMAIL']." <".$row_sendlist['EMAIL']."></br>";
                    
                    if (@
    mail($toemail,stripslashes($subject),stripslashes($message),stripslashes($headers)))
                    {
                        echo 
    "Mail to:".$row_sendlist['EMAIL']." confirmed.</br>";
                    }
                    else
                    {
                        echo 
    "Mail to".$row_sendlist['EMAIL']." failed.</br>";
                    }
                }
            }
        }
    ?>

    Phew!

    I've also put in the option for merge fields (i.e. parts of the design that will change depending on who it goes to) in the form of <<<NAME>>>. When the php loops through each record, it replaces this set of characters with the value from each recordset...

    It even tells you if they've worked!

    Happy coding!

  5. #5
    wjh2303 is offline x10 Sophmore wjh2303 is an unknown quantity at this point
    Join Date
    Mar 2009
    Posts
    139

    Re: Mailing list implimentation.

    thanks alot, that looks great, ill have a play around with it

  6. #6
    casenote is offline x10Hosting Member casenote is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    1

    Re: Mailing list implimentation.

    How do you implement the mailing list that is supplied in the cpanel of x10hosting?
    I set up a mailing list, but do not know how to add a form to add users to the list?
    Is there a tutorial on this somewhere?

    Thanks,
    Casey

+ Reply to Thread

Similar Threads

  1. Mailing list
    By Fsmvda in forum Free Hosting
    Replies: 0
    Last Post: 10-16-2008, 04:36 PM
  2. Mailing list fails to deliver the message
    By maclan in forum Free Hosting
    Replies: 12
    Last Post: 09-09-2008, 11:49 AM
  3. I need database to mailing list help
    By mpband in forum Programming Help
    Replies: 1
    Last Post: 07-02-2008, 09:55 PM
  4. Free mailing list provider
    By Charis Core in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 12-28-2007, 02:01 AM
  5. Mailing List
    By Usman in forum Feedback and Suggestions
    Replies: 4
    Last Post: 09-26-2005, 08:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers