Mail function not delivering

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tutu saint
    New Member
    • Jun 2011
    • 21

    #1

    Mail function not delivering

    The below given was supposed to send emails to subscribers but the mail is not being delivered.

    Please help.


    Code:
      $allemails="select email from members";
      //mysql_select_db($database_dbCon, $dbCon);
      mysql_select_db($database,$db_connect) or die( "Unable to select database");
      $Result = mysql_query($allemails, $db_connect) or die(mysql_error());
     
    //  $str="";
      while($row=mysql_fetch_array($Result)){
      
       $to=$row[0];
    $sender="<gospel@domain.com>";
    // Your subject
    $subject="Gospel Alert from domain.com";
    
    // From
    $header="from: Gospel Alart <news@domain.com>";
    
    // Your message
    $messages= "Your daily news alert  has returned the following alert for you today\r\n";
    //$messages= "<a href=http://alart1.php</a><br>";
    // send email
    $sentmail = mail($to,$subject,$messages,$header);	
      //$str.="-".$sentmail;
      if($sentmail)
      echo("Mail sent to ".$row[0]." successfully<br/>");
      else
      echo("Mail not delivered to ".$row[0]." successfully<br/>");
      }
    But these mail are not being delivered to my email. Please what could be the cause
  • Murat Bastas
    New Member
    • Jul 2012
    • 25

    #2
    What is value in row[0]? If row[0] == receiver's email address fetch_array function is using $row['columnName'].

    I think was problem in your sql management.

    You check array of $row...

    Comment

    • tutu saint
      New Member
      • Jun 2011
      • 21

      #3
      Murat,
      Row[0] containes receivers email addresses.
      line 25 of the codes echoes the result and says "Mail sent to addd@add.com successfully" but the mails are not delivered.

      Comment

      • Murat Bastas
        New Member
        • Jul 2012
        • 25

        #4
        I cant see an error...

        Code:
        function sendMail($toMail,$fromName,$fromMail,$subject,$message) {
            $headers = "MIME-Version: 1.0\n"; 
            $headers .= "Content-type: text/html; charset=utf-8\n"; 
            $headers .= "X-Mailer: PHP\n"; 
            $headers .= "X-Sender: PHP\n"; 
            $headers .= "From: $fromName<$fromMail>\n"; 
            $headers .= "Subject: $subject<$fromMail>\n"; 
            $headers .= "Reply-To: $fromName<$fromMail>\n"; 
            $headers .= "Return-Path: $fromName<$fromMail>\n"; 
            mail($toMail,$subject,$message,$headers) or die ('Error in send mail function.');
            return true;
        }
        Please try it. I using this function all time. And it is works without error.

        Comment

        Working...