简体   繁体   中英

Cakephp: Email Error SSL

config->email.php

public $gmail = array(
    'host' => 'ssl://mail.myserver.co.in:465',
    'username' => 'support@myserver.co.in',
    'password' => 'secret',
    'transport' => 'Smtp',
    'template' =>false,
    'layout' => false,
);

function to send email

public function sendEmail() {

    $layout = "gmail";
    $Email = new CakeEmail();
    $Email -> config('gmail');
    $Email -> from(TEST_FROM);
    $Email ->to(TEST_EMAIL);
    $Email -> subject('Welcome to TaskBucks');
    $Email -> emailFormat('html');
    if ($Email -> send()) {
        return true;
    } else
        return false;

}

Error i am facing

stream_socket_client(): SSL operation failed with code 1. OpenSSL
Error messages: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
stream_socket_client(): Failed to enable crypto
stream_socket_client(): unable to connect to
ssl://mail.rapidsoft.co.in:465:25 (Unknown error)

Your script is right.

The reason is because you can't send email from your local machine. You need to configure sending email from your local machine then your cakephp sendMail function works.

Here is one of the way you can configure your local machine to send email. If you are using WAMP

http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/

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