PHP Simple Correction ( PHP Expert please help to me..! )

Discussion in 'PHP' started by actress143, May 12, 2010.

  1. #1
    Hear i have added 560 Email Ids into my database, but i have to send the mail at a time.
    so the column is 'email', for sendig the email for that particular column of emails i have used the following script.., but it giving the message

    Message delivery failed...,


    What's wrong please help it is very important for me
    Thanks a lotttt.




    <table class="ex"> <td>
    
    <?php
    include('db_n.php');
    
    
    $data = mysql_query("SELECT * FROM appsubmitn") or die(mysql_error()); 
    
    Print "<table CLASS=b> Send Mail To All The Clients In Your Database: "; include('header.php'); ?> 
    
    
    
    
    <?php
    while($info = mysql_fetch_array( $data )) 
    { 
    Print "<tr>";
    
    
    //___________sending mail__________
    
    $to = "info['email']";
    
    $subject = "Hi!";
    
    $body = "Hi,\n\nHow are you?";
    
    if (mail($to, $subject, $body)) {
    
      echo("<p>Message successfully sent!</p>");
    
     } else {
    
      echo("<p>Message delivery failed...</p>");
    
     }
    
    
    //___________end mail__________
    
    
     
    
    Print "<td>".$info['email']. "</td>";
    
    
    
    
    } 
    
    Print "</table>"; 
    
    ?>
    
    
    
    
    </td></table>
    
    PHP:
     
    actress143, May 12, 2010 IP
  2. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's possible that some emails aren't well formatted in which case mail() would fail.
    It's also possible that you don't have a working mail system on your server.
    Check your php.ini and see if a sendmail_path is set.
     
    musicmasteria, May 12, 2010 IP
  3. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #3
    $to = "info['email']"; <--

    $to = $info['email'];
     
    gapz101, May 12, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Use $to = $info['email']; and not $to = info['email'];
    And also check whether the emails are valid or not :)
     
    roopajyothi, May 12, 2010 IP
  5. musicmasteria

    musicmasteria Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ha so all the emails were invalid because the $to variable was empty/null/whatever.
    I should have seen that missing $ before info.
     
    musicmasteria, May 12, 2010 IP
  6. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks my dear friends....,

    and special thanks to roopajyothi, gapz101

    Yours working 100.1% thank you a lot
     
    actress143, May 12, 2010 IP