0

Hope all of my experts are fine. Buddy's i stuck in a very simple code. Actually i have to insert a form and then fetch values from it to send mail to the user who fills the form. All the values are inserting into the database and also fetch from database but mail is not sending. The same code was sending mail one day ago. But today it is not sending mail. Please help me out in this.

<?php

    require("dbconnect.php");
    require("DBConnection.php");


    session_start();

    if(isset($_POST['postadd'])){

    $title = $_POST['adtitle'];
    $area = $_POST['area'];
    $addesc = $_POST['addesc'];
    $email = $_POST['email'];
    $showemail = $_POST['showemail'];
    $userpic = ($_FILES['pic1']['tmp_name']);
        $compath = "UploadPictures/".md5($_FILES['pic1']['name']);
        $comFileType=$_FILES['pic1']['type'];
        $comFileSize=$_FILES['pic1']['size'];
        $comFileSize=$comFileSize/1024;

            if($comFileSize<1000)
            {
                $arrFileType=array("image/jpeg","image/png","image/gif","image/bmp");
                if(in_array($comFileType,$arrFileType))

                {

                    move_uploaded_file($userpic,$compath);
                }
                else
                {
                    ("Invalid Image Format");   
                }
            }
            else
            {
                ("File Size Error");    
            }

            $pic2 = ($_FILES['pic2']['tmp_name']);
        $compath2 = "UploadPictures/".md5($_FILES['pic2']['name']);
        $comFileType2=$_FILES['pic2']['type'];
        $comFileSize2=$_FILES['pic2']['size'];
        $comFileSize2=$comFileSize2/1024;

            if($comFileSize2<1000)
            {
                $arrFileType2=array("image/jpeg","image/png","image/gif","image/bmp");
                if(in_array($comFileType2,$arrFileType2))

                {

                    move_uploaded_file($pic2,$compath2);
                }
                else
                {
                    ("Invalid Image Format");   
                }
            }
            else
            {
                ("File Size Error");    
            }

        $pic3 = ($_FILES['pic3']['tmp_name']);
        $compath3 = "UploadPictures/".md5($_FILES['pic2']['name']);
        $comFileType3=$_FILES['pic3']['type'];
        $comFileSize3=$_FILES['pic3']['size'];
        $comFileSize3=$comFileSize3/1024;

            if($comFileSize3<1000)
            {
                $arrFileType3=array("image/jpeg","image/png","image/gif","image/bmp");
                if(in_array($comFileType3,$arrFileType3))

                {

                    move_uploaded_file($pic3,$compath3);
                }
                else
                {
                    ("Invalid Image Format");   
                }
            }
            else
            {
                ("File Size Error");    
            }

        $pic4 = ($_FILES['pic4']['tmp_name']);
        $compath4 = "UploadPictures/".md5($_FILES['pic4']['name']);
        $comFileType4=$_FILES['pic4']['type'];
        $comFileSize4=$_FILES['pic4']['size'];
        $comFileSize4=$comFileSize4/1024;

            if($comFileSize4<1000)
            {
                $arrFileType4=array("image/jpeg","image/png","image/gif","image/bmp");
                if(in_array($comFileType4,$arrFileType4))

                {

                    move_uploaded_file($pic4,$compath4);
                }
                else
                {
                    ("Invalid Image Format");   
                }
            }
            else
            {
                ("File Size Error");    
            }
        $agree = $_POST['checkbox'];
        $subcat = $_SESSION['subcat'];
        $cat = $_SESSION['cat'];
        $rand = rand();
        $datecreated = date("Y-m-d h:i:s");

            $obj = new DBConnection();
            $arr_Field = array("title","location","post","email","radio","pic1","pic2","pic3","pic4","agree","cat","subcat","random","datecreated");
            $arr_values = array("$title","$area","$addesc","$email","$showemail","$compath","$compath2","$compath3","$compath4","$agree", "$cat", "$subcat" ,"$rand","$datecreated");
            $obj->InsertRecord("ads",$arr_Field,$arr_values) or die (mysql_error());

            $object = new DBConnection();
                $condition = "ORDER BY id DESC LIMIT 1";
                $selquery = $object->SelectRecord(array("*"),"ads","$condition") or die(mysql_error()); 
                while($get = mysql_fetch_array($selquery)){
                $email = $get['email'];
                $id = $get['id'];
                }
                //echo $email;
                //exit();

$to = $email;
$subject = "Admin";

$message = "
<html>
<head>
<title>Admin</title>
</head>
<body>
<p>Please Click on this Link to verify your post</p>
<p><a href='http://almughnisolutions.com/almughniclassified/summary.php?summary=".$id."'>http://almughnisolutions.com/almughniclassified/summary.php?summary=".$id."</a></p>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: <[email protected]>' . "\r\n";

mail($to,$subject,$message,$headers) or die("Mail Cannot sent");

            //header("Location:verifyadd.php");

    }

    ?>
5
  • Create a new file with just the mail function in it. It's likely something to do with your SMTP settings or something... Commented Nov 14, 2012 at 4:31
  • can you tell me which type of hosting do you have? Commented Nov 14, 2012 at 4:31
  • if your are able to send mail yesterday with that same script that mean script doesn't have any error it probably because of they seem to have a queue... it only sends every hour/half hour or depends on queue Commented Nov 14, 2012 at 4:33
  • i am not getting any error. Except the mail is not sending. Commented Nov 14, 2012 at 4:34
  • mail could not be send from yesterday night. Commented Nov 14, 2012 at 4:35

1 Answer 1

1

It would probably be a safe assumption that your code is not to blame. A cursory review of it seems like it shuold work if the SMPT server is behaving correctly. I would recommend testing the server. There are a some web based tools to do this:

https://www.wormly.com/test_smtp_server

You could also just use telnet to test from your machine if it's something that will need to be done internally:

http://technet.microsoft.com/en-us/library/aa995718%28v=exchg.65%29.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.