php模块之 Codeigniter 发送邮件

PHP语言: 临时自用代码
<?php if ( ! defined( 'BASEPATH')) exit( 'No direct script access allowed');

class Myemail extends CI_Controller {

        function __construct()
        {
                parent :: __construct();
        }

        function index()
        {
                $this -> load -> view( 'welcome_message');
        }

        function sendmail()
        {
        //config
                $this -> load -> library( 'email');

        $config [ 'protocol' ] = 'smtp';
        $config [ 'smtp_host' ] = 'ssl://smtp.gmail.com';
        $config [ 'smtp_user' ] = '[email protected]';
        $config [ 'smtp_pass' ] = 'yourpasswd';
        $config [ 'smtp_port' ] = '465';
        $config [ 'smtp_timeout' ] = '5';
        $config [ 'newline' ] = " /r/n ";
        $config [ 'crlf' ] = " /r/n ";
        $this -> email -> initialize( $config);
       
       
       

        $this -> email -> from( '[email protected]' , 'yourname');
        $this -> email -> to( '[email protected]');
        $this -> email -> subject( 'Myemail TT');
        $this -> email -> message( 'This is TEST one!');
        $this -> email -> send();
        }
   
}
?>

你可能感兴趣的:(php模块之 Codeigniter 发送邮件)