0

我有一个用于发送基本电子邮件的代码。但对于 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'; 的情况下完成了这项工作,但是当我添加该行时,根本无法发送电子邮件:(

4

1 回答 1

0

If you do not want to actually send an email and instead want to test out the functionality, you can use the following delivery option:

Copy to Clipboard
$this->Email->delivery = 'debug';
于 2012-05-03T06:53:17.867 回答