設定 Kohana 透過 Gmail 發信

有了之前設定 CodeIgniter 透過 Gmail 發信的經驗, 這次設定 Kohana 就快很多了 :p

不過 CodeIgniter 是 email library, 而 Kohana 則是 email helper (實際上是使用 swift mailer)。

設定檔 /application/config/email.php

$config['driver'] = 'smtp';
$config['options'] = array(
    'hostname' => 'smtp.gmail.com',
    'username' => 'your_username',
    'password' => 'your_password',
    'port' => 465,
    'encryption' => 'tls'
);```

然後接著就可以用以下的 code 來發信啦!

$to = [email protected]'; $from = [email protected]'; $subject = 'email subject'; $message = 'Hello, World!'; email::send($to, $from, $subject, $message);```

tzangms

Read more posts by this author.

Subscribe to Oceanic / 海海人生

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!