简体   繁体   中英

phpmailer was working as of 12/4 prior to 2pm est

ok so im at 30 hours non stop trying to figure out this code as to why it stopped working out of nowhere and its really starting to piss me off now.

it is a production server and was working just fine until title time.

here is my testemail.php that did work prior to this date-time.

<?php
require 'include\smtp\class.phpmailer.php';
require 'include\smtp\class.smtp.php';
set_time_limit(3600);
date_default_timezone_set('Etc/UTC');
$mail = new PHPMailer();  // create a new object

$mail->Timeout = 3600;
$mail->IsHTML();
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 4;  // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;  // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; 
$mail->Username = "email";
$mail->Password = "pass";        
$mail->SetFrom( "email",  "Do Not Reply");
$mail->Subject = "test";
//$mail->AddAttachment($dir.str_replace("/", "\\", $row2["eventpdf"]));
$mail->Body = "testing";
$mail->AddAddress("email");

if(!$mail->Send()) {
    $error = 'Mail error: '.$mail->ErrorInfo; 
    } else {
    $error = 'Message sent!';

    }
    ?>

UPDATE:

i updated my class.phpmailer.php and class.smtp.php to vs 5.2.26 from github and applied the work around of

$mail->SMTPOptions = array(
'ssl' => array(
    'verify_peer' => true,
    'verify_peer_name' => false,
    'allow_self_signed' => true
)
);

right before the if(!$mail line. this is a temp solution while i figure out why the ssl cert is pulling it from the wrong location and where to set the proper one. its pulling stuff from /usr/local/ssl however this is a windows machine and thinks its a linux one. also not using any prepackaged amp system. im using all separate installs. apache/php/mysql all alone.

fyi:

the verify_peer once set to true is what causes the issue. you can change anything else to true/false and it will send. once you change verify_peer to true it stops.

Fixed correctly. Under PHPMailer troubleshooting download a new cacert.pem and inside your php.ini you need to scroll to the bottom(at least mine was at bottom) or search for cafile or capath and add the path and file. File needs to be the complete path to it because it gave me an error of it wasn't. Like c:\\certs\\cacert.pem then restart your Apache server and either change verify_peer to true or remove all smtpoptions and it sends emails again with a certificate. Unsure if it works with any other certs but did with the one I downloaded from the site listed on troubleshooting PHPMailer page on GitHub.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM