0

i have sendnewmail function using it send mail,in mail message is send message dispaly but in gmail its not coming ,this is the code

function sendnewmail($msgnew,$emailidnew,$subjectnew){
   require_once("class.phpmailer.php");
      require_once("class.smtp.php");
         $mail = new PHPMailer();
      $mail->IsSMTP();     // set mailer to use SMTP
      $mail->Host = "mail.domain.com"; // specify main and backup server
      $mail->SMTPAuth = true;     // turn on SMTP authentication
      $mail->Username ="user";  // SMTP username
      $mail->Password ="password"; // SMTP password
      $mail->From = "abcds@gmail.com";
      $mail->FromName = "name";
      $mail->AddAddress($emailidnew,"sudeshna");
      $mail->WordWrap = 50;                                 // set word wrap to 50 characters
      $mail->IsHTML(true);                                  // set email format to HTML
          $mail->Subject = $subjectnew;
      $mail->Body    = $msgnew;
          if(!$mail->Send())      {
        echo "Message could not be sent. <p>";
         echo "Mailer Error: " . $mail->ErrorInfo;
         exit;
  }else{
          echo 'Message send ok';
      }
}
$htmldetails ="Welcome to World";
$email = "abc@gmail.com";
$subject = "Sample welcome message";
sendnewmail($htmldetails,$email,$subject);



Sudeshna
  • 19
  • 5
  • **in gmail its not coming** did you use gmail for the smtp server? that being said, for testing, better off using local server (such as [fakesmtp](http://nilhcem.com/FakeSMTP/)) so you can be sure that the app actually sending email first then you can worry smtp server dropping your mails (due to reasons, e.g. spam) later.. – Bagus Tesa Feb 19 '20 at 06:56
  • mail send to gmail (abc@gmail.com) account – Sudeshna Feb 19 '20 at 07:05
  • You're using an old version of PHPMailer. [Get the latest](https://github.com/PHPMailer/PHPMailer). If you're sending through gmail, base your code on [the gmail example provided](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps), and read [the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). – Synchro Feb 19 '20 at 09:29

1 Answers1

-1

hope this work

  function sendnewmail($msgnew,$emailidnew,$subjectnew){
  require_once("PHPMailer/class.phpmailer.php");
  require_once("PHPMailer/class.smtp.php");
  $mail = new PHPMailer();
  $mail->isSMTP();
  $mail->Host = "mail.domain.com"; // specify main and backup server
  $mail->Port = 465;

  $mail->SMTPSecure = 'ssl';

  $mail->SMTPAuth = true;
  $mail->Username ="user";  // SMTP username
  $mail->Password ="password"; // SMTP password
  $mail->From = "abc@domain.com";
  $mail->FromName = "name";
  $mail->AddAddress($emailidnew,"sudeshna");
  $mail->WordWrap = 50;                         
  $mail->IsHTML(true);                       
      $mail->Subject = $subjectnew;
  $mail->Body    = $msgnew;
      if(!$mail->Send())      {
    echo "Message could not be sent. <p>";
     echo "Mailer Error: " . $mail->ErrorInfo;
     exit;
  }else{
      echo 'Message send ok';
  }
 }
 $htmldetails ="Welcome to World";
 $email = "tausifahmad810@gmail.com";
 $subject = "Sample welcome message";
 sendnewmail($htmldetails,$email,$subject);
Tausif
  • 420
  • 2
  • 15