Welcome Guest. Please Login or Register  


You are here: Index > AMPPS > General Support > Topic : Can't use PHPMailer in my local server?



Threaded Mode | Print  

 Can't use PHPMailer in my local server? (1 Replies, Read 77 times)
conf
Group: Member
Post Group: Newbie
Posts: 2
Status:
I have done all what I could to fix it but I can't

this is my code
PHP Code

<?php
// 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;

require 
'PHPMailer/src/Exception.php';
require 
'PHPMailer/src/PHPMailer.php';
require 
'PHPMailer/src/SMTP.php';

$mail = new PHPMailer(true);                              // Passing `true` enables exceptions
try {
    
//Server settings
    
$mail->SMTPDebug 3;                                 // Enable verbose debug output
    
$mail->isSMTP();                                      // Set mailer to use SMTP
    
$mail->Host 'smtp.gmail.com';  // Specify main and backup SMTP servers
    
$mail->SMTPAuth true;                               // Enable SMTP authentication
    
$mail->Username 'myemail@gmail.com';                 // SMTP username
    
$mail->Password 'password!';                           // SMTP password
    
$mail->SMTPSecure 'tls';                            // Enable TLS encryption, `ssl` also accepted

    
$mail->Port 587;   // for tls                                 // TCP port to connect to

    //Recipients
    
$mail->setFrom('myemail@gmail.com''Conf');
    
$mail->addAddress('myemail@gmail.com''Joe User');     // Add a recipient

    
$mail->addReplyTo('no-replay@example.com''No Replay');


    
//Content
    
$mail->isHTML(true);                                  // Set email format to HTML
    
$mail->Subject 'Here is the subject';
    
$mail->Body    'This is the HTML message body <b>in bold!</b>';
    
$mail->AltBody 'This is the body in plain text for non-HTML mail clients';

    
$mail->send();
    echo 
'Message has been sent';
} catch (
Exception $e) {
    echo 
'Message could not be sent. Mailer Error: '$mail->ErrorInfo;
}
?>



  • Iam using Mac
  • I have used gmail smtp and mailtrap.io
  • ssl is working in my Ampps


thats the error message I've got
------------

2019-02-12 09:22:34 Connection: opening to smtp.gmail.com:587, timeout=300, options=array()
2019-02-12 09:22:36 Connection: opened
2019-02-12 09:22:36 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP h15sm2823758eds.51 - gsmtp
2019-02-12 09:22:36 CLIENT -> SERVER: EHLO localhost
2019-02-12 09:22:37 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [188.240.101.192]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2019-02-12 09:22:37 CLIENT -> SERVER: STARTTLS
2019-02-12 09:22:38 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2019-02-12 09:22:39 Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed [/Applications/AMPPS/www/resetPassDemo/PHPMailer/src/SMTP.php line 405]
SMTP Error: Could not connect to SMTP host.
2019-02-12 09:22:39 CLIENT -> SERVER: QUIT
2019-02-12 09:22:40
2019-02-12 09:22:40
2019-02-12 09:22:40 Connection: closed
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.
IP: --   

Can't use PHPMailer in my local server?
conf
Group: Member
Post Group: Newbie
Posts: 2
Status:
I had the answer...

to add
PHP Code

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


IP: --   

« Previous    Next »

Threaded Mode | Print  



Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is February 17, 2019, 4:41 pm.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.414