0

Hi I am using PHP mailer 6.1.6 to send emails using a gmail account. This is my code

$mail = new PHPMailer(true);
try {
    //Server settings                     // Enable verbose debug output
    $mail->isSMTP();                                            // Send using SMTP
    
    $mail->Host       = 'smtp.gmail.com';                    // Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->Username   = 'me@gmail.com';                     // SMTP username
    $mail->Password   = 'mypassword';                               // SMTP password
    
    
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; 
    
    
    // $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         
    // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port = 465;          

// TCP port to connect to //use 465 for

    //Recipients
    $mail->setFrom('me@gmail.com','Me');
    $mail->addAddress($eemail);

It shows the following error.

Message could not be sent. Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Please suggest a fix for gmail, yahoo mail or any other service. Thanking in anticipation

user173819
  • 47
  • 1
  • 6

0 Answers0