SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    Rep of Ireland
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mail autoresponder activation

    This is the code that I have installed in what I call process_sub.php. which is demonstrated at this TEST LINK

    The page accounts for the following processes on a simple submit email form:
    Part 1. //VALIDATE THE SUBMITTED EMAIL
    Part 2. //WRITE VALIDATED EMAIL TO LIST
    Part 3. //SEND AUTORESPONDER MESSAGE

    Parts 1 and 2 of the code works. When part 3 of the code is introduced it throws a 500 error.

    The process I seek to manage is as follows. A visitor submits an email which is validated and entered to, and stored in a flatfile List. I am seeking also that an autoresponse is forwarded to the submitters email address.

    I seek to find if I am on the right track in Part 3 of the code! Any direction / resolution greatly appreciated.

    PHP Code:
    <html><head>
    <title>Write Subscribe to List....</title>
    </head><body>
    <br />
    <?php
                      
        
    //Part 1.  VALIDATE THE SUBMITTED EMAIL
        
    $Email   $_POST['Email'];
        
    $Email htmlspecialchars($_POST['Email']);
        if (!
    preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$Email)) {
            die(
    "Please enter a valid email address....!<br /><br />Use the Go Back Button to return to the SUBMIT EMAIL Form");
            }        
            
        
    //Part 2.  WRITE VALIDATED EMAIL TO LIST
        
    $List    $_POST['List'];
        if (
    file_exists("data/$List")) {
            
    $myfile file("data/$List");
            
    $fh fopen("data/$List""w");
            for (
    $index 0$index count($myfile); $index++) {
                if (
    $Email != rtrim($myfile[$index])) {
                    
    fputs($fh$myfile[$index]);
                }
            }
            
    fputs($fh$Email "\n");
            
    fclose($fh);
        } else {
            
    $myfile fopen("data/$List""w");
            
    fputs($myfile$Email "\n");
            
    fclose($myfile);
        }
        
    //SEEKING TO INSTALL THE AUTORESPONDER CODE HERE TO FUNCTION
    //AFTER VISITOR EMAIL HAS BEEN SUBMITTED, VALIDATED AND ADDED TO LIST.
    // This Part 3 of the code when introduced throws a 500 error....?


        //Part 3.  SEND AUTORESPONDER MESSAGE
        
    $From    $_POST['From'];         
        
    $Body    $_POST['Body'];
        
        
    $Body =  readfile("data/autoresponder.txt");        
        
    mail("$Email","Welcome to my mailing list.!",
        
    "$Body","From: Author of Mail\nReply-To: home@gmail.com");
        
    $addresses file("data/$List");
        
    $addresses file("data/Email.lst");
        
    $fh fopen("data/Email.lst","a");
        for (
    $index=0$index count($addresses); $index++)
        {
        if (
    $Email != trim($addresses[$index]))
        {
    fputs($fh,$myfile[$index]);}
        }
        
    fputs($fh,$Email."\n");
        
    fclose($myfile);
        
    ?>
    <br><br>
    Thank you for subscribing to our E-mail List!        
    <br><br>
    <a href="index.php">Back to Home Page</a>.
    </body></html>

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Hi webiter
    A 500 is usually a server config error which will be recorded in the error log. If you have access to the logs, have a look what it says.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    Rep of Ireland
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi spikeZ & Sitepoint,

    Now got error logging going at Test Position.
    Script lines in question on page process_sub.php numbered as attached image.post.jpg

    The following is extracted from the error_log.txt

    Notice: Undefined index: $From in C:\CustomerData\webspaces\webspace_00156450\wwwroot\postbox.webitry.net\process_sub.php on line 42

    The following is the current configuration of line 42 $From = $_POST['$From'];

    Guidence/direction needed to get this issue resolved...!

    ************************************************************
    ************************************************************

    The following is also recorded in the error_log.txt


    [09-Jan-2012 19:36:39] PHP Notice: Undefined variable: List in C:\CustomerData\webspaces\webspace_00156450\wwwroot\postbox.webitry.net\editnames.php on line 11

    The following is the content of line 11 <?php echo $List ?>.

    Again guidence/direction needed to get this issue resolved...!

    The following is the code for the editnames.php page.

    PHP Code:
    <html><head><title>Edit Maillist addresses</title></head><body>
    <table cellspacing="10" border="2" bordercolor="blue" ><tr><td>

    <form method="post" action="writenamefile.php">
    <b>Editing E-mail details for List...</b><br />
    <?php echo $List ?>.  <!--SHOULD THERE BE ADDITIONAL LIST SELECTION HERE..?-->
    Fix an address by editing <br />in place, or remove an address<br />
    by deleting the WHOLE line altogether.<br />  
    <b>No blank LINES or SPACES allowed! </b>
    <br><br><textarea cols="27" rows="20" name="Body">

    <?php
     
        $List  
    $_POST['List'];
        if (
    file_exists("data/$List")) 
        {
    readfile("data/$List");}
        
    ?>

    </textarea>
    <br>
    <input type="hidden" name="List" value="<?php echo $List ?>">
    <input type="submit" name="submit" value="Save This List">
    </form>

    <a href="addnames.php">Add names to the list</a>.
    <br><a href="data/log.txt">View Send Log</a>.
    </td></tr></table></body></html>
    Thanks for assisting.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    You have to define a variable before you can use if.
    You call $list on line 11 but dont define it till later in the script:
    PHP Code:
    $List  $_POST['List']; 
    and line 42 should be
    PHP Code:
     $From $_POST['From']; 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    Rep of Ireland
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry spikeZ I may not have framed my question all that well.

    Line 42 is as you have indicated $From = $_POST['From']; and it is presenting the error - Notice: Undefined index: $From in C:\CustomerData\webspaces\webspace_00156450\wwwroot\postbox.webitry.net\process_sub.php on line 42

    The line 11 is a different page and a different issue. Perhaps I should not have presented the line 11 issue here.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    Rep of Ireland
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks and much appreciated, I have got rid of the two errors that were presenting. I edited line as follows: $From = 'myemail@gmail.com';

    I note the following items arising that I could do with some direction on:

    1. When the email arrives from the autoresponder it only presents with the number of characters in the message! (ie not the message but just a numerical value as in 145) . Does this mean that the $Body = readfile("data/autoresponder.txt"); line of the code is in some way faulty?

    2. How might I go about hiding the autoresponder message from the visitor? All I want the visitor to see on screen is the Thank you for subscribing to our E-mail List! and the Go Back button.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •