0

当我在 IndexController.php 中使用以下代码时,我收到代码下方显示的错误:

IndexController.php 中的代码

<?php

class IndexController extends Zend_Controller_Action

{

public function init()
{
    /* Initialize action controller here */
}

public function indexAction()
{

    $config = array
    (
        'auth' => 'login',
        'username' => 'mymail@gmail.com',
        'password' => 'mypass',
        'ssl' => 'ssl',
        'port' => 465,
    );


    $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

    $mail = new Zend_Mail();
    $mail->addTo('othermail@gmail.com', 'me' )
         ->setFrom('mymail@gmail.com', 'me')
         ->setSubject('your trial at fitness first')
         ->setBodyText('email body in plain text')
         ->send($transport);
}

}

页面上显示的错误:

An error occurred

Application error

我从未编辑过任何其他文件,只是安装了zend并创建了一个新项目并按照教程所说的继续......

但是我被卡住了@上面的错误

4

2 回答 2

1

这解释起来相当复杂,但我试试。

当 ZF 发生错误时,通常会抛出异常。这将启动您的 ErrorController。

在那个 ErrorController 中,您只能在指定时获得堆栈跟踪和错误消息

phpSettings.display_errors = 1

application/configs/application.ini为您当前使用APPLICATION_ENV

看看: http: //framework.zend.com/manual/en/zend.application.quick-start.html那里描述了它是如何工作的。设置 APPLICATION_ENV 的一种简单方法是将其放入.htaccess文件中

SetEnv APPLICATION_ENV development

这一切都在链接中描述。然后编辑您的application/configs/application.ini喜欢:

[development]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
于 2011-12-14T20:24:41.843 回答
0

如果您使用的是 Gmail,请尝试将配置更改为:

$config = array
    (
        'auth' => 'login',
        'username' => 'mymail@gmail.com',
        'password' => 'mypass',
        'ssl' => 'tls',
        'port' => 587,
    );

如果可以,你之前版本的问题应该是你的php.ini文件中没有开启openssl

于 2011-12-15T09:17:42.527 回答