cakephp 4.x丢失的板块异常定义了EmailTransport URL
内部 app_local.php
:
'EmailTransport' => [
'default' => [
'className' => MailTransport::class,
/*
* The keys host, port, timeout, username, password, client and tls
* are used in SMTP transports
*/
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
/*
* It is recommended to set these options through your environment or app_local.php
*/
//'username' => null,
//'password' => null,
'client' => null,
'tls' => false,
'url' => 'myCompany-org.mail.protection.outlook.com'
],
],
当前,当我将 url
属性设置为字符串时,应用程序崩溃了,以下错误:
如果 url
的值为null,则应用程序不会崩溃。
Fatal error: Type of Cake\View\Exception\MissingTemplateException::$file must be string (as in class Exception) in C:\xampp\htdocs\creative_trak_2\vendor\cakephp\cakephp\src\View\Exception\MissingTemplateException.php on line 23
我认为这可能是一个路由问题,但我不知道MailTransport使用的任何路线。由于我使用的是React Router,因此我的应用是一个单页应用程序,我的 doutes.php
文件看起来像:
$routes->scope('/', function (RouteBuilder $builder) {
// Single Page Application
$builder->connect('/*', ['controller' => 'Pages', 'action' => 'main']);
$builder->connect('/users/{action}', ['controller' => 'Users']);
$builder->connect('/pages/*', 'Pages::display');
$builder->fallbacks();
});
我检查了我的 logs
,并且没有出现错误。任何建议都感谢如何进一步调试此问题。
谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在看到的错误消息是因为您使用的是与您的PHP版本不兼容的CakePHP( https://github.com/cakephp/cakephp/cakephp/pull/15529 )。升级到最新的4.x以查看实际错误。
话虽如此,这不是有效的DSN字符串,这是
url
选项的目的。有效的DSN字符串至少由架构和主机组成,例如:对于您的外部主机,您很可能需要更多详细信息,用户名密码等...,一个更完整的示例是:
不是您' D如果您想进行硬码内容,则需要在此处使用DSN字符串。无论如何,首先要了解您需要连接到Outlook的详细信息,然后从那里开始。
另请参见
The error message that you're seeing is because you're using a version of CakePHP that is not compatible with your PHP version (https://github.com/cakephp/cakephp/pull/15529). Upgrade to the latest 4.x to see the actual error.
That being said, that's not a valid DSN string, which is what the
url
option is meant to be used with. A valid DSN string consists of at least a schema and a host, like:For your external host you'd most likely need more details of course, username password, etc..., a more complete example would be:
Not that you'd need to use a DSN string here if you want to hardcode things. Anyhow, first figure the details that you need to connect to outlook, and then go from there.
See also https://book.cakephp.org/4/en/core-libraries/email.html#configuring-transports