【发布时间】:2012-08-08 10:27:06
【问题描述】:
我使用下面的代码作为 sendGrid 代码,用于从我的项目发送邮件。
require_once(YII_BASE_PATH . "/lib/sendgrid-php/SendGrid.php");
require_once(YII_BASE_PATH . "/lib/sendgrid-php/SendGrid_loader.php");
$sendgrid = new SendGrid('uname', 'pwd');
$mail = new SendGrid\Mail();
$mail->addTo('xxxxxxxxxx@gmail.com')->
setFrom('xxxyyyy5@yahoo.co.in')->
setSubject('Subject goes here')->
setText('Hello World!')->
setHtml('<strong>Hello World!</strong>');
$sendgrid->smtp->send($mail);
我已经下载了sendGrid包,放到yii的lib文件夹中了。
如果我执行上面的代码,我会得到类似"include(Swift_DependencyContainer.php): failed to open stream: No such file or directory"的错误
如果我包含了上述文件,我会遇到错误,例如需要包含另一个文件。
请就此提出建议。
【问题讨论】:
-
回显
YII_BASE_PATH。我认为它的价值不是你所期望的。 -
@PLB YII_BASE_PATH 返回基本路径,我给出了定义('YII_BASE_PATH')或定义('YII_BASE_PATH',dirname(FILE));在 index.php 中
-
我认为问题不在于 YII_BASE_PATH :2 require_once 工作(错误是关于 Swift_DependencyContainer.php,而不是 SendGrid.php 或 SendGrid_loader.php)。