php - PHPMailer doesn't send mail to gmail -


i trying send mail through phpmailer. seems work fine, mails sent email not show on gmail (when using google apps) shows in outlook or mobile email. think i'm going wrong headers somewhere. please me.

tried question first got no answer.

phpmailer file:

<?php  require('phpmailer/class.phpmailer.php');  if(isset($_post['email'])) {      // edit 2 lines below required     //$email_to = "info@rsadvisories.com";     //$email_subject = "request portfolio check ".$first_name." ".$last_name;      $title = array('title', 'mr.', 'ms.', 'mrs.');     $selected_val = $_post['title'];     $first_name = $_post['first_name']; // required     $last_name = $_post['last_name']; // required     $email_from = $_post['email']; // required     $telephone = $_post['telephone']; // not required     $comments = $_post['comments']; // required      function clean_string($string) {       $bad = array("content-type","bcc:","to:","cc:","href");       return str_replace($bad,"",$string);     }      $email_message = "name: ".$selected_val." ".clean_string($first_name)." ".clean_string($last_name)."<br />email id: ".clean_string($email_from)."<br />telephone no: ".clean_string($telephone)."<br />details: ".clean_string($comments);     $allowedexts = array("doc", "docx", "xls", "xlsx", "pdf"); $temp = explode(".", $_files["file"]["name"]); $extension = end($temp); if ((($_files["file"]["type"] == "application/pdf") || ($_files["file"]["type"] == "application/msword") || ($_files["file"]["type"] == "application/excel") || ($_files["file"]["type"] == "application/vnd.ms-excel") || ($_files["file"]["type"] == "application/x-excel") || ($_files["file"]["type"] == "application/x-msexcel") || ($_files["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_files["file"]["type"] == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) && ($_files["file"]["size"] <= 20000) && in_array($extension, $allowedexts))   {   if ($_files["file"]["error"] != 0)     {     echo "<script>alert('error: " . $_files["file"]["error"] ."')</script>";     }   else     {         $d='upload/';         $de=$d . basename($_files['file']['name']);     $u=move_uploaded_file($_files["file"]["tmp_name"], $de); $filename = $_files['file']['name'];     $filepath = $_files['file']['tmp_name'];      //add if file upload      //if($u)      //echo "uploaded!";      }   }   elseif (!(file_exists($_files['file']['tmp_name'])) || !(is_uploaded_file($_files['file']['tmp_name'])))  { echo "<script> alert('warning : no file uploaded, email sent without attachments');</script>"; } else   {    die("<script>alert('invalid file'); window.location.href='main.php';</script>");   }  // create email headers $headers = 'from: '.$email_from."\r\n". 'reply-to: '.$email_from."\r\n" . 'x-mailer: php/' . phpversion(); //create new phpmailer instance $mail = new phpmailer(); //tell phpmailer use smtp $mail->issmtp(); //enable smtp debugging // 0 = off (for production use) // 1 = client messages // 2 = client , server messages $mail->smtpdebug  = 2; //ask html-friendly debug output $mail->debugoutput = 'html'; //set hostname of mail server $mail->host       = "***"; //set smtp port number - 25, 465 or 587 $mail->port       = 25; //whether use smtp authentication $mail->smtpauth   = false; //username use smtp authentication $mail->username   = "***"; //password use smtp authentication $mail->password   = "***"; //set message sent $mail->setfrom($email_from, $first_name.' '.$last_name); $mail->addcustomheader($headers); //set alternative reply-to address //$mail->addreplyto('replyto@example.com','first last'); //set message sent $mail->addaddress('***', 'ritu shah'); $mail->from=$email_from; //set subject line $mail->subject = 'request portfolio check up'; //read html message body external file, convert referenced images embedded, convert html basic plain-text alternative body $mail->body=$email_message; //replace plain text body 1 created manually $mail->altbody = 'this plain-text message body'; //attach image file //$mail->addattachment($file); $mail->addattachment($de); //send message, check errors if(!$mail->send()) {   echo "<script>alert('mailer error: " . $mail->errorinfo."')</script>"; } else {     die();     $headers1 = 'from: ***'."\r\n". 'reply-to: ritu@rsadvisories.com'."\r\n" . 'x-mailer: php/' . phpversion();    mail($email_from,'re:request portfolio check up','we have received mail. contact soon.',$headers1);    echo "<script>alert('your request has been submitted. contact soon.');window.location.href='main.php';</script>"; } } ?> 

debug message (no file uploaded, hence not access file):

could not access file:  smtp -> server:220-gator1545.hostgator.com esmtp exim 4.80 #2 tue, 03 sep 2013 11:35:53 -0500 220-we not authorize use of system transport unsolicited, 220 and/or bulk e-mail. client -> smtp: ehlo rsadvisories.com smtp -> server: 250-gator1545.hostgator.com hello rsadvisories.com [216.172.167.28]250-size 52428800250-8bitmime250-pipelining250-auth plain login250-starttls250 client -> smtp: mail from:<ayushkster@gmail.com> smtp -> server:250 ok client -> smtp: rcpt to:<ritu@rsadvisories.com> smtp -> server:250 accepted client -> smtp: data smtp -> server:354 enter message, ending "." on line client -> smtp: date: tue, 3 sep 2013 11:35:53 -0500 client -> smtp: return-path: <ayushkster@gmail.com> client -> smtp: to: ritu shah <ritu@rsadvisories.com> client -> smtp: from: ayush khemka <ayushkster@gmail.com> client -> smtp: subject: request portfolio check client -> smtp: message-id: <cb1ac1dd52e8724a2e536ea35058be19@rsadvisories.com> client -> smtp: x-priority: 3 client -> smtp: x-mailer: phpmailer 5.2.6 (https://github.com/phpmailer/phpmailer/) client -> smtp: from: ayushkster@gmail.com client -> smtp: reply-to: ayushkster@gmail.com client -> smtp: x-mailer: php/5.2.17 client -> smtp: mime-version: 1.0 client -> smtp: content-type: multipart/alternative; client -> smtp: boundary="b1_cb1ac1dd52e8724a2e536ea35058be19" client -> smtp: content-transfer-encoding: 8bit client -> smtp:  client -> smtp: --b1_cb1ac1dd52e8724a2e536ea35058be19 client -> smtp: content-type: text/plain; charset=iso-8859-1 client -> smtp: content-transfer-encoding: 8bit client -> smtp:  client -> smtp: plain-text message body client -> smtp:  client -> smtp:  client -> smtp: --b1_cb1ac1dd52e8724a2e536ea35058be19 client -> smtp: content-type: text/html; charset=iso-8859-1 client -> smtp: content-transfer-encoding: 8bit client -> smtp:  client -> smtp: name: mr. ayush khemka<br />email id: ayushkster@gmail.com<br />telephone no: 09930754012<br />details:  client -> smtp:  client -> smtp:  client -> smtp:  client -> smtp: --b1_cb1ac1dd52e8724a2e536ea35058be19-- client -> smtp:  client -> smtp: . smtp -> server:250 ok id=1vgta5-0001jh-9p client -> smtp: quit smtp -> server:221 gator1545.hostgator.com closing connection 

try change these lines:

$mail->port       = 25;  $mail->smtpauth   = false; 

to

$mail->port       = 485;  $mail->smtpauth   = true; 

remember change login/password settings


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -