php - Contact Form Says Successful But Not Sending The Email -


this question has answer here:

i have contact form allows users upload attachments. odd because when use contact form, success message appears when check email, receive nothing either in inbox or spam folder. however, files attach message appear in /upload folder part seems working correctly.

it's don't receive message or anything. i'm not sure what's wrong. code pasted below.

 <?     if($_server['request_method'] == "post")      {                                                             $allowedexts = array("gif", "jpeg", "jpg", "png", "doc", "pdf", "docx",  "jpg", "docx", "odt", "txt", "msg", "csv", "pps", "ppt", "pptx", "xml", "tar", "m4a", "mp3", "wav", "wma", "mp4", "mov", "flv", "exe");    ($i = 1; $i <= 2; $i++) {  $temp = explode(".", $_files["attach".$i]["name"]);  $extension = end($temp);  if (in_array($extension, $allowedexts)) {   move_uploaded_file($_files["attach".$i]["tmp_name"],   "upload/" .$_post["firstname"]."-".$_files["attach".$i]["name"]);  }  }   $to      = 'myemail@gmail.ca';  $subject = 'consultation '.$_post["firstname"];  $message = $_post["message"]."\n\n\n attachments: ".$_files["attach1"]["firstname"]." ".$_files["attach2"]["firstname"]." ".$_files["attach3"]["firstname"];   $firstname=$_request['firstname'];   $companyname=$_request['companyname'];   $email=$_request['email'];    if (($firstname=="")||($email=="")||($message==""))       {       echo "<strong><p class =greentip>a first name, message, , email   required, please fill <a href=/consult.php>the form</a> again.</p></strong><br>";      }    else{     mail($to, $subject, $message, $firstname, $email);  echo "<strong><p class = greentip>your free consultation request has    been received! expect detailed response within next 3 hours.</p></strong>";      }   }   ?>     <form  action="" method="post" enctype="multipart/form-      data">                         <strong>first name *</strong><br>  <input name="firstname" type="text" value=""><br>  <strong>company name </strong><br>  <input name="companyname" type="text" value=""><br>   <strong>email *</strong><br>  <input name="email" type="text" value=""<br>   <strong>your message *</strong><br>  <textarea name="message" rows="7" cols="30" placeholder="in query, include , revelant information pertaining nature of writing request. more specific in request, more complete in our response!"></textarea><br>   <strong>attachments</strong><br>      <input name = "attach1" type="file" class="file" />    <br>        <input name = "attach2" type="file" class="file" />    <br><br>    <center><input type="submit" value="submit"></center> <br>     </form> 

edit: using mail() function incorrectly. function accepts:

mail($to, $subject, $message, $optional_headers, $optional_additional_params);

the way trying pass $firstname , $email wrong. please see docs.

====================================================================

the php mail() function basic. returns boolean value indicating success, when returns true there many things have gone wrong preventing email delivery mail() won't know about.

in experience gmail has become extremely picky receiving emails. used if didn't have correct headers email land in spam folder, nowadays i've seen change gmail doesn't accept email @ all.

you can find lot of information googling "php mail going spam gmail" since used emails @ least went spam folder. , unfortunately problem more complex setting headers correctly, email server config , things go along have right also.

https://serverfault.com/questions/449244/php-mail-to-gmail-spam

sending email via php mail function goes spam


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -