Advanced Search

Results 1 to 2 of 2

Thread: Sending auto message after email subscription

  1. #1
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default Sending auto message after email subscription

    Seeking to get this subscribe email/validate email/autorespopnder message to subscriber script, working so that I can install within a website.

    It is not a large machine and I only want a facility to manage at max 400 - 600 emails without having to use the mySQL apparatus.

    I have same set up and running to a extent at this link location

    Workings of the script are as follows:

    1. Visitor submits an email into a website field.
    2. The email is validated with javascript/php.
    3. The validated email is added to a Master list.
    4. An on screen Thank You notice is presented to the visitor.
    5. Autoresponder sends a presaved message to the visitors email.
    6. Another visitor can repeat the above and the list grows.
    7. I can then copy and paste the Master list
    entries on a monthly basis to the sublists Jan, Feb, Mar, etc.
    8. I can then tailor monthly messages by selecting from the various email sublists.

    Some problems that I am aware of currently
    1. A blank line is being saved in the Master list when a email is submitted. Not sure if same is of consequence but I do not know why it is occuring.
    2. Autoresponder is sending a email to my email address but it does not present the message - only the number (the size of the file) in the message. See image of email attached.
    3. I want to be sure that the autoresponder script is only selecting the last email entry from the Master list each time.
    4. The Thank You message and the autoresponder message currently present on the screen as the process completes. Only the Thank You message should present pon screen.


    The //VALIDATE THE SUBMITTED EMAIL & the //WRITE VALIDATED EMAIL TO LIST parts of this page code seems to work fine on their own bar the apparant saving of blank lines to the master list!

    The //SEND AUTO MESSAGE TO VISITOR not working to requirements!

    The following is the code that forms the processor?

    PHP Code:
    <html><head> 
    <title>Write to List/Send Auto....</title> 
    </head><body><center> 
    <table cellspacing="10" border="2" bordercolor="blue"><tr><td><center>
    <?php
         
        
    //VALIDATE THE SUBMITTED EMAIL    
        
    $Email htmlspecialchars($_POST['Email']);
        if (!
    preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$Email)) {
            echo 
    '<br /><a href="http://www.postbox.webitry.net/subscribe.html" onClick="history.go(-1)"><h3>> Go Back to Email Submit Form <</h3></a><br />';
            die(
    "<h3>and enter a valid Email Address..!</h3>");    
        }
                
        
    //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);
        }
        
        
    //SEND AUTORESPONDER MESSAGE TO VISITOR
        //$From    = $_POST['From'];
        
    $From 'p-------@gmail.com';
        
    $Body =  readfile("data/autoresponder.txt");        
        
    mail("$Email","Welcome to my mailing list.!""$Body","From:  $From\nReply-To: $From");
        
    $addresses file("data/$List");
        
    $fh fopen("data/$List","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>
    <!--THE FOLLOWING IS THE ON SCREEN MESSAGE THAT THE VISITOR RECEIVES-->
    Thank you for subscribing to our E-mail List!        
    <br><br>
    <a href="index.php">Back to Home Page</a>.
    <br /><br /></center></td></tr></table></center></body></html>
    Any advice greatly appreciated.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	me.jpg 
Views:	78 
Size:	10.3 KB 
ID:	4275  
    Last edited by Webiter; 01-14-2012 at 08:34 AM. Reason: Complete and Format the query

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,167
    Thanks
    62
    Thanked 446 Times in 435 Posts
    Blog Entries
    7

    Default

    readfile("data/autoresponder.txt");
    (or any of the other filesystem functions)
    might fail if your file permissions are wrong, or if your server is not set up to support them (and/or if the file doesn't exist). It shouldn't return a 500 error, though. How did you localize the problem to this part of the code?

    also,
    Please use the forum's bbcode tags and indent your code to make it more readable:

    for php code............[php] <?php /* code goes here */ ?> [/php]
    for html...............[html] <!-- markup goes here -->.....[/html]
    for js/css/other.......[code] code goes here................[/code]
    Adrian ~ facebook | gist/github

    ['66.215.156.37','208.75.149.97'] // ip,ip array!
    "Take that sticker *off* your hat; you look stupid" --Wil Wheaton

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
  •