SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot iStudent's Avatar
    Join Date
    Mar 2004
    Location
    So Cal
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Email Newsletter Not Working

    I built an email newsletter system, to send out an email to every email address stored in the database once at a time.

    But for some unknown reason, when I send out the email virtually no one gets it. I get it on my yahoo account and on my ISP account, but thatís it. Iíve contacted some of the people on the email list to see if they got it, but no one has.

    The only thing I can thing of is somewhere (ether my end, or there end) a spam blocker was setup to stop mass emails from getting in. But the problem with is, the loop get one email address, then sends the email, then it repeats.

    Here is my code:

    PHP Code:

            $Subject 
    $_POST['Subject']; 
            
    $Body $_POST['Body'];
            
            
    $headers "From: Bob Smith <bob@smith.com>\n";
            
            
    $results = @mysql_query('SELECT * FROM email1 ORDER BY ID ASC');
            
            while (
    $email mysql_fetch_array($results)) 
            
                {    
                    
                    
    mail($email[Address],$Subject,$Body,$headers);
                    
                    echo 
    $email[ID] . '. Email sent to ' $email[Address] . '<br />';
        
                } 

  2. #2
    SitePoint Evangelist Andrewaclt's Avatar
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've not run into this problem personally, and it's not clear to me as to what exactly you are asking. Have you asked your host about the possibility of a spam filter on your end?

    Have you tried setting more specific mail headers? Such as: (taken from php.net)

    PHP Code:
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "X-Priority: 1\n";
    $headers .= "X-MSMail-Priority: High\n";
    $headers .= "X-Mailer: php\n"
    Another offtopic note: It's probally better to specify the fields you want in your select statement rather than use *.

    PHP Code:
    $results = @mysql_query('SELECT Address,ID FROM email1 ORDER BY ID ASC'); 

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if u send multiple emails then use
    PHP Code:
    function mailTo($subject$message$headers) {
    $count mysql_num_rows($ret);
    for(
    $i 0$i <= $count; ++$i) {
    $row mysql_fetch_row($ret);
    $str .= $row['Adress'][$i].",";
    }
    $to substr($str0strlen($str) - 1);
    mail($to,$subject,$message,$headers);
    }

    switch (
    $_POST["send_mail"]) {
    case 
    true;
    mailTo();
    break;

    note the comma...

    cheers

  4. #4
    SitePoint Zealot iStudent's Avatar
    Join Date
    Mar 2004
    Location
    So Cal
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the problem, I called up my hosting company, and they said its because on the receiving end there spam filters setup blocking the IP address of my site.

    So they said call up some of the receiving end domains, and find out what spam filters they use. Then they can contact the company and try got get the IP address off the block list.

    Does anyone know of another way to fix this?

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your script is wrong!

  6. #6
    SitePoint Zealot iStudent's Avatar
    Join Date
    Mar 2004
    Location
    So Cal
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I added stuff to my code, and still some of the people don't get the newsletter.

    PHP Code:

            $Subject 
    $_POST['Subject']; 
            
    $Body $_POST['Body'];
            
            
    $headers "From: Bob Smith <bob@smith.com>\n";
            
            
    $headers .= "Reply-to: Bob Smith <bob@smith.com>\n"
            
            
    $headers .= "MIME-Version: 1.0\n"
            
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n"
            
    $headers .= "X-Priority: 1\n"
            
    $headers .= "X-MSMail-Priority: Normal\n"
            
    $headers .= "X-Mailer: php\n";
            
            
    $results = @mysql_query('SELECT * FROM email ORDER BY ID ASC');
            
            while (
    $email mysql_fetch_array($results)) 
            
                {    
                    
                    
    mail($email[Address],$Subject,$Body,$headers);
                    
                    echo 
    'Email sent to ' $email[Address] . '<br />';
        
                } 

  7. #7
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Madison, WI
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by reminder
    if u send multiple emails then use
    PHP Code:
    function mailTo($subject$message$headers) {
    $count mysql_num_rows($ret);
    for(
    $i 0$i <= $count; ++$i) {
    $row mysql_fetch_row($ret);
    $str .= $row['Adress'][$i].",";
    }
    $to substr($str0strlen($str) - 1);
    mail($to,$subject,$message,$headers);
    }

    switch (
    $_POST["send_mail"]) {
    case 
    true;
    mailTo();
    break;

    note the comma...

    cheers

    i don't know much about working with databases, but it's my intuition that this function won't work unless the query result ($ret) is explicitly passed to it in the functions arguements, such as
    PHP Code:
    function mailTo($subject$message$headers$ret) {
       
    // function stuff here

    am i correct in thinking this?


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
  •