Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用swiftmailer嵌入文件时出错_Php_Symfony_Swiftmailer - Fatal编程技术网

Php 使用swiftmailer嵌入文件时出错

Php 使用swiftmailer嵌入文件时出错,php,symfony,swiftmailer,Php,Symfony,Swiftmailer,我试图整理一个文件,以便自动响应。 我的控制器里有这个: $message = \Swift_Message::newInstance(); $imgUrl = $message->embed(Swift_Image::fromPath('http://hpics.li/5395483')); $message->setSubject('Demande de devis bien reçue !') ->setFrom('xxx@

我试图整理一个文件,以便自动响应。 我的控制器里有这个:

$message = \Swift_Message::newInstance();
    $imgUrl = $message->embed(Swift_Image::fromPath('http://hpics.li/5395483'));
    $message->setSubject('Demande de devis bien reçue !')
                ->setFrom('xxx@gmail.com')
                ->setTo($devis->getEmail())
                ->setBody(
                    $this->renderView(
                        'OAHDevisBundle:Devis:devis_email.html.twig',array('url'=>$imgUrl)
                        ),
                    'text/html'
                    );

        $this->get('mailer')->send($message); 
但我有以下错误:

Attempted to load class "Swift_Image" from namespace "OAH\DevisBundle\Controller".
Did you forget a "use" statement for another namespace?

我的代码有问题吗?我可以添加什么来解决我的问题?谢谢

您忘了添加斜杠来表示
\Swift\u Image
的全局名称空间,谢谢!对不起……不用担心。发生了