1

i already check if openssl is used by my wamp server and it is check. But what is the problem of my code?

$mail = new PHPMailer(true); 
$body             = 'THIS IS YOUR USERNAME:'.$row['username'].' PASSWORD: '.$row['password'].'\n PLEASE DELETE THIS MESSAGE AFTER YOU READ THIS';
$mail->SMTPDebug = 1;
$mail->IsSMTP();                // tell the class to use SMTP
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 587;                    // set the SMTP server port
$mail->SMTPSecure = 'tsl'; 
$mail->Host = 'smtp.gmail.com';
$mail->Username   = "dan.villarea22@gmail.com";     // SMTP server username
$mail->Password   = "password";            // SMTP server password
$mail->AddReplyTo("system@dvts.com","ADMIN");
$mail->From       = "system@dvts.com";
$mail->FromName   = "SYSTEM";
$to = "dan.villareal22@gmail.com";
$mail->AddAddress($to);
$mail->Subject  = "First PHPMailer Message";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap   = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();echo 'Message has been sent.';
Daniel Villareal
  • 63
  • 1
  • 1
  • 7

3 Answers3

8

Change $mail->SMTPSecure = 'tsl' to $mail->SMTPSecure = 'tls'

demircan
  • 231
  • 4
  • 9
2

Try changing the host option as follows:

$mail->Host = "ssl://smtp.googlemail.com";

Seyfin
  • 21
  • 1
0

Try using $mail->Port = 465; instead of 587 and check the difference in the below link.
What is the difference between ports 465 and 587?

Community
  • 1
  • 1
Rahul Ukil
  • 111
  • 1
  • 1
  • 6