【问题标题】:sending email using cakephp via smtp通过 smtp 使用 cakephp 发送电子邮件
【发布时间】:2012-05-03 06:44:48
【问题描述】:

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

【问题讨论】:

  • 您正在使用调试选项,请尝试删除它
  • 同样的事情 yossi..实际发生的是页面加载了几秒钟,然后它不会发送任何电子邮件... :(
  • 第一:你得到的错误是什么?
  • 不发送时,只要调试模式设置为2,就不会显示任何错误。

标签: php email cakephp sendmail


【解决方案1】:

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

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

【讨论】:

  • 那里。我让它工作了,但问题是......我检查了它是否真的是用于发送我的邮件的 smtp,所以我故意输入了错误的密码,但它仍然发送了一封电子邮件......>.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-06
  • 2017-05-12
  • 2011-10-28
  • 1970-01-01
  • 1970-01-01
  • 2013-08-22
相关资源
最近更新 更多