php - Cannot send email using PHPMailer -


i trying send email using phpmailer. code have written.

    $mail = new phpmailer;      $mail->issmtp();     $mail->host = 'smtp.gmail.com';     $mail->smtpauth = true;     $mail->username = 'shamir.towsif@gmail.com';     $mail->password = '*********';     $mail->port = 25;      $mail->from = 'shamir.towsif@gmail.com';     $mail->fromname = 'shamir towsif';     $mail->addaddress('shamir.towsif@gmail.com', 'shamir towsif');     $mail->addreplyto('shamir.towsif@gmail.com', 'information');      $mail->ishtml(true);      $mail->subject = 'here subject';     $mail->body    = 'this html message body <b>in bold!</b>';     $mail->altbody = 'this body in plain text non-html mail clients';      if(!$mail->send()) {         echo "message not sent.\n";         echo "mailer error: " . $mail->errorinfo;     } else {         echo 'message has been sent';     } 

here error getting.

message not sent. mailer error: smtp connect() failed. 

what doing wrong. other questions in not helping. in advance.

i facing similar problem, think should try adding code:

$mail->port = 587; $mail->smtpsecure = 'tls'; 

this phpmailer recommended settings gmail, can see example in github page .


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -