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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -