phpmailer - Can not send email with php mailer using gmail account -


here cannot send email phpmailer using gmail account. sample code:

<?php require_once('phpmailerclass/class.phpmailer.php');  $mail = new phpmailer(); $mail->issmtp(); $mail->mailer = 'smtp'; $mail->smtpauth = true; $mail->host = 'smtp.gmail.com';  $mail->port = 568; $mail->smtpsecure = 'ssl';  $mail->username = "myemail@gmail.com"; $mail->password = "mypassword";  $mail->ishtml(true); // if going send html formatted emails  $mail->from = "ramalingam.p@pickzy.com"; $mail->fromname = "ramalingam";  $mail->addaddress("yoursramalingam@gmail.com","luu van minh");  $mail->subject = "testing phpmailer localhost"; $mail->body = "hi,<br /><br />this system working perfectly.";  if(!$mail->send()) {      echo "message not sent <br />phpmailer error: " . $mail->errorinfo; }    else {     echo "message has been sent"; }       ?> 

response error:

message not sent  phpmailer error: following address failed: myemail@gmail.com 

i enable 'less secure' in gmail settings. throw above error. specifying valid gmail address. please correct wrong.

if use ssl change port 587 465

$mail->port = 465; $mail->smtpsecure = 'ssl'; 

https://support.google.com/a/answer/176600?hl=en


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -