电子邮件不是在localhost中的cakephp 3.x中发送的

时间:2015-12-15 05:08:24

标签: php cakephp

这里我试图从localhost发送电子邮件。我已经在php.ini和sendmail.ini文件中配置了smtp服务器设置。我的代码更改是

app.php

  'EmailTransport' => [
        'default' => [
            'className' => 'Smtp',
            // The following keys are used in SMTP transports
            'host' => 'ssl://smtp.gmail.com',
            'port' => 465,
            'timeout' => 30,
            'username' => '******',
            'password' => '********',
           // 'client' => null,
           // 'tls' => null,
        ],
    ],
'Email' => [
        'default' => [
            'transport' => 'default',
            'from' => '**********',
        //'charset' => 'utf-8',
        //'headerCharset' => 'utf-8',
        ],
    ],

控制器代码。

$email = new Email('default');
    try {
        $res = $email->from('*****@**.**')
              ->to(['*****@**.**' => 'My Website'])
              ->subject('Tsting')                   
              ->send("hiii this is for testing ");

    } catch (Exception $e) {

        echo 'Exception : ',  $e->getMessage(), "\n";

    }

0 个答案:

没有答案