1

I have used sparkpost email for my website http://hlwmm.org. I have used php Phpmailer library with Sparkpost SMTP. It was working fine but its not working now. Below is my code

// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';

$mail = new PHPMailer;
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.sparkpostmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'SMTP_Injection';
$mail->Password = 'XXXXXXXXXXXXXXXXXXXXXXXX';

$mail->setFrom('inquiry@hlwmm.org');

$mail->addAddress($to);
$mail->Subject = "Test Subject";
$mail->Body = "Test Sparkpost Email";

$mail->send();

I am getting below error

2018-08-03 05:55:31 SERVER -> CLIENT: 220 2.0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.39.65390 r(Core:4.2.39.50) Fri, 03 Aug 2018 05:55:31 +0000
2018-08-03 05:55:31 CLIENT -> SERVER: EHLO hlwmm.org
2018-08-03 05:55:31 SERVER -> CLIENT: 250-b.mta1vsmtp.cc.aws-usw2b.prd.sparkpost says EHLO to 162.214.3.26:35530250-ENHANCEDSTATUSCODES250-8BITMIME250-PIPELINING250-AUTH=LOGIN PLAIN250-AUTH LOGIN PLAIN250 STARTTLS
2018-08-03 05:55:31 CLIENT -> SERVER: STARTTLS
2018-08-03 05:55:31 SERVER -> CLIENT: 220 2.0.0 continue
SMTP Error: Could not connect to SMTP host.
2018-08-03 05:55:31 SMTP NOTICE: EOF caught while checking if connected
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Error

Thanks

  • Search & read docs before you post. It's failing after issuing `STARTTLS`, which is covered in the troubleshooting guide the error message links to. You probably need to update your CA certificates bundle. – Synchro Aug 03 '18 at 06:37
  • Any solutions? I'm getting the same exact error with sparkpost – MrPHP Oct 03 '18 at 07:40
  • I used other email service. You can use SparkPost API instead of its STMP. I think it will work. – Pradeepta Khatoi Oct 04 '18 at 13:25
  • 1
    HI @MrPHP, My same code was working fine in other server so some issue was with server. SparkPost not supporting TLSv1.0 now. https://www.sparkpost.com/docs/tech-resources/tlsv1-0-test-hostname/ – Pradeepta Khatoi Oct 04 '18 at 13:44
  • Update: SparkPost now requires (at least) TLSv1.2 support in your client, for good reasons. https://www.sparkpost.com/blog/upgrading-tls-1-2/ – tuck1s Sep 21 '21 at 16:13

0 Answers0