<?php
use Zend\Mail;
$mail = new Mail\Message();
$mail->setBody('This is the text of the email.');
$mail->setFrom('Freeaqingme@example.org', 'Sender\'s name');
$mail->addTo('Matthew@example.com', 'Name of recipient');
$mail->setSubject('TestSubject');
$transport = new Mail\Transport\Sendmail();
$transport->send($mail);
?>以上代码来自Zend官方网站,网址是http://framework.zend.com/manual/2.3/en/modules/zend.mail.introduction.html。
当运行上述代码时,会出现以下错误:
致命错误:在第5行的D:\xampp\htdocs\1\t1.php中找不到类'Zend\Mail\Message‘
我已经将放在我的include_path=".;D:\xampp\php\PEAR;D:\xampp\htdocs\ZendFramework-2.3.3\library“文件中
我是否需要在代码开头加上代码"require_once(*)“?
我是一个初学者,希望收到一些详细的答案,最好添加什么代码。
谢谢!
发布于 2017-11-27 18:10:24
检查composer.json的内容。尝试:
composer require zendframework/zend-mail发布于 2021-10-06 06:32:34
composer require zendframework/zend-mail这将解决您的问题,但是在Magento2.3.4中,它们删除\Zend* all类。
Magento将Zend/类添加到层中。
所以试试这个
$mail = new Laminas\Message()而不是
$mail = new Mail\Message();https://stackoverflow.com/questions/26140870
复制相似问题