Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect via TLS #30

Closed
weierophinney opened this issue Dec 31, 2019 · 8 comments
Closed

Unable to connect via TLS #30

weierophinney opened this issue Dec 31, 2019 · 8 comments
Assignees
Labels
Question Further information is requested

Comments

@weierophinney
Copy link
Member

I have a problem when I send mail to client to Reset Password. I using Gmail

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\wamp64\www\zend2112\vendor\zendframework\zend-mail\src\Protocol\Smtp.php on line 216

Here is my function:

function sendMailWithToken($user){
        $token = $user->getToken();
        $http = isset($_SERVER['https']) ? 'https://': "http://";
        $domail = $_SERVER['HTTP_HOST'];
        $link = $http.$domail.'/zend/public/set-password/'.$token;

        $messageBody = "Hello ".$user->getFullname(). ',\n';
        $messageBody.="Click the LINK below to reset your password: \n";
        $messageBody.=$link;
        $messageBody.=".\nThanks and Best Regards!";

        $html = new MimePart($messageBody);
        $html->type = "text/html";

        $body = new MimeMessage();
        $body->setParts(array($html));


        $message = new Message();
        $message->setEncoding("UTF-8");
        $message->addFrom('[email protected]', 'Forget Password');
        $message->addTo($user->getEmail());
        $message->setSubject('Forget Password');
        $message->setBody($body);

        // Setup SMTP transport
        $transport = new SmtpTransport();
        $options   = new SmtpOptions([
            'name' => 'smtp.gmail.com',
            'host' => 'smtp.gmail.com',
            'port' => 587,
            'connection_class'=>'login',
            'connection_config'=>[
                'username' =>'[email protected]',
                'password' => 'password',
                'ssl'      => 'tls',
                
            ],           
        ]);
        $transport->setOptions($options);
        $transport->send($message);
    }

Thanks for reading. I try to fix 2 days. Please help !!!


Originally posted by @phantien94 at zendframework/zend-mail#202

@weierophinney
Copy link
Member Author

I have the same issue.
Did you solve it somehow?


Originally posted by @ZoltanDobrovolni at zendframework/zend-mail#202 (comment)

@weierophinney
Copy link
Member Author

Your system CA certificates are most likely stale. If on linux check for ca-certs or ca-certificates package. Try to update it first.

If that does not work you need to point ini option to a fresh cafile location:
https://secure.php.net/manual/en/openssl.configuration.php

Take a look at https://github.com/paragonie/certainty
It is an easy way to get fresh ca certificates bundle file.

I, personally, prefer to use this script from curl library to obtain latest certificates directly from mozilla during php setup:
https://github.com/curl/curl/blob/master/lib/mk-ca-bundle.pl

This component might have a configuration option to provide those explicitly to be set as a stream context, I didn't check.


Originally posted by @Xerkus at zendframework/zend-mail#202 (comment)

@weierophinney
Copy link
Member Author

Thanks for your help!

Unfortunatelly, we could not make it working with updated certificates.
So we avoided the problem with other solution.


Originally posted by @ZoltanDobrovolni at zendframework/zend-mail#202 (comment)

@weierophinney
Copy link
Member Author

What was it?

Thanks for your help!

Unfortunatelly, we could not make it working with updated certificates.
So we avoided the problem with other solution.


Originally posted by @RAIMUNDOS54 at zendframework/zend-mail#202 (comment)

@weierophinney
Copy link
Member Author

Not sure if this helps, but anyway...
I was able to connect to my GMail account after enabling "Less secure applications" on it's settings.


Originally posted by @galvao at zendframework/zend-mail#202 (comment)

@khangzoro97
Copy link

kkk

@khangzoro97
Copy link

i dont know how to connect via TLS , it's very difficult.

@Ocramius
Copy link
Member

Ocramius commented Aug 9, 2021

Closing here as per #30 (comment)

These errors are raised at lower level, and laminas/laminas-mail is just raising the exception, and making them visible.

@Ocramius Ocramius closed this as completed Aug 9, 2021
@Ocramius Ocramius self-assigned this Aug 9, 2021
@Ocramius Ocramius added the Question Further information is requested label Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants