Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting - simple way to solve it
Next
Answered
Emma Rault
  • 28
Emma Rault
Asked: May 18, 20222022-05-18T10:11:53+00:00 2022-05-18T10:11:53+00:00In: php

Smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting – simple way to solve it

  • 28

. Advertisement .

..3..

. Advertisement .

..4..

How to solve the problem – smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting?
I have the sample detail:

<?php 
 
 include('header.php');
 require 'PHPMailerAutoload.php';
 $message='';
 
 if(isset($_POST["submit"]))
 {
  $path='upload/'.$_FILES["resume"]["name"];
  move_uploaded_file($_FILES["resume"]["tmp_name"], $path);
 
  $mail = new PHPMailer;
 
 $mail->SMTPDebug = 0; // Enable verbose debug output
 
 $mail->isSMTP(); // mailer to use SMTP
 $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
 $mail->SMTPAuth = true; // Enable SMTP authentication
 $mail->Username = '[email protected]'; // SMTP username
 $mail->Password = 'mypasswordgoeshere'; // SMTP password
 $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
 $mail->Port = 465; // TCP port to connect to
 
 $mail->From=$_POST['email'];
 $mail->FromName=$_POST['name'];
 $mail->setFrom($_POST['email']);
 $mail->addAddress('[email protected]'); 
 
 $mail->AddCC($_POST['name'],$_POST['email']);
 
 $mail->WordWrap=50;
 
 $mail->AddAttachment($path);
 
 $mail->Subject='application for job';
  // Add a recipient
  // Name is optional
 $mail->addReplyTo($_POST['email']);
 
 $mail->isHTML(true); // Set email format to HTML
 
 //$mail->Subject = $_POST['subject'];
 $mail->Body = $_POST['message'];
 $mail->AltBody = $_POST['message'];
 
 
 
 if(!$mail->send()) {
  echo '<script>alert("Message could not be sent.")</script>';
  echo 'Mailer Error: ' . $mail->ErrorInfo;
 } else {
  echo '<script>alert("Message has been sent");
 
  window.location.href="career.php";
  </script>';
 
 }
 
 
 }
 
 ?>

While I was running it, I found the warning message:

Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

That is my question in my midterm exam, and it is urgent.
I searched the solutions on some websites, but I didn’t get it. I may miss any line or other changes. I appreciate your assistance!

smtp connect() failed.
  • 2 2 Answers
  • 138 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    hdtutoria Expert
    2022-06-10T04:10:46+00:00Added an answer on June 10, 2022 at 4:10 am

    The cause: This error indicates that your script is unable to connect to your SMTP server.
    The solution: I recommend starting over: get the most recent version of PHPMailer, follow one of the available examples, and tweak it to fit your own server. Set $mail->SMTPDebug = 3; to see what happens when you try to connect to the server. All of this is in the issue template (which you erased) as well as the troubleshooting instructions to which your error message refers.

    • 11
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Maël Favre
    2022-05-25T20:12:08+00:00Added an answer on May 25, 2022 at 8:12 pm

    Have you changed your gmail security settings? Change your less secure app access to turn it on

    • 16
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.