繁体   English   中英

通过smtp使用cakephp发送电子邮件

[英]sending email using cakephp via smtp

我有一个用于发送基本电子邮件的代码。 但对于smtp,我无法完善此功能:

        function send(){

            $this->Email->smtpOptions = array(
                'port'=>'465', 
                'timeout'=>'30',
                'host' => 'ssl://smtp.gmail.com',
                'username'=>'csorila@gmail.com',
                'password'=>'mypassword',
           );

        $this->Email->delivery='smtp';

            $this->Email->send = 'debug';

            $this->Email->to = 'csorila17@gmail.com'; 
        $this->Email->subject = 'hurrah'; 
//        $this->Email->replyTo = 'noreply@example.com'; 
        $this->Email->from = 'Charmaine Khay Sorila<noreply@example.com>'; 
        //$this->Email->send('Here is the body of the email Chams Email Test');
        //Set the body of the mail as we send it. 
        //Note: the text can be an array, each element will appear as a 
        //seperate line in the message body. 

        if ( $this->Email->send() ) { 
            $this->Session->setFlash('Simple email sent'); 
        } else { 
            $this->Session->setFlash('Simple email not sent'); 
            $this->set('smtp_errors', $this->Email->smtpError);
        } 
        }

    }

我在没有$ this-> Email-> delivery ='smtp';的情况下工作了,但是当我添加该行时,根本无法发送电子邮件:(

如果您不想实际发送电子邮件,而是想测试功能,则可以使用以下传递选项:

Copy to Clipboard
$this->Email->delivery = 'debug';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM