Quick Php Mail Script

Discussion in 'PHP' started by Silver89, Sep 10, 2007.

  1. #1
    Hi,

    I need a quick script that will import emails from a text file seperated by ,

    and then email each.


    The rest i can manage, just finding this part a tad tricky.

    Thanks for your help.

    :)
     
    Silver89, Sep 10, 2007 IP
  2. Sphinks

    Sphinks Active Member

    Messages:
    1,102
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Read that file, use "explode" function to put all email into an array, parse the array and send an email to each address.
     
    Sphinks, Sep 10, 2007 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    <?php
    function grabpage($url, $ref, $user, $timeout)
      {  
     /* Grabpage function by Danltn
      * Please leave in this line to use, it is invisible to your users
      * Feel free to contact me if you so need, URL: http://danltn.com
      */  
       if (!function_exists('curl_init') or !function_exists('curl_exec')) { 
        return file_get_contents($url);
        } else {    
        if (!$timeout or $timeout == 0) { $timeout = 10; }
        if (!$user) { $user = "Microsoft Internet Exploder"; }
        if (!$ref) { $ref = "http://www.google.com/search?q=".rand(0,1000)."+facts&ie=utf-8&oe=utf-8"; }         
        $ch = curl_init();  
        curl_setopt($ch, CURLOPT_URL, $url);    
        curl_setopt($ch, CURLOPT_REFERER, $ref);    
        curl_setopt($ch, CURLOPT_USERAGENT, $user);        
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);    
        $output = curl_exec($ch);    
        curl_close($ch);    
        return $output;   
      } }
      
    $data = grabpage("emails.txt","","",5);  
    $data = explode("\n",$data);  
    for ($i=0; $i < count($data); $i++) {
    
    echo $data[$i];
    // Rest of mail command here
    
    }
    
    ?>
    PHP:
    This should get you started.
     
    Danltn, Sep 10, 2007 IP