Laravel:SwiftMailer Class' Lib \ Services \ Mail \ Swift_Attachment'未找到

时间:2014-05-28 04:39:28

标签: php laravel-4

我试图在Laravel中使用Swiftmailer发送附件。这是我的邮件课程。

public function sendContactUsPrize(array $input, $fremail, $star, $name, $landing, $attachment)
    {
           //get contact us email for db


        if ($star)
        {
            Mail::send('Emails.ContactAct', $input, function($message) use($input, $fremail, $star, $name, $landing, $attachment)
            {
                   $message->to($star)
                           ->subject($name." has contacted you on https://seek.estate".$landing)
                           ->attach(Swift_Attachment::fromPath($attachment));

                   $message->to($fremail)
                           ->subject($name." has submitted leads on https://seek.estate".$landing)
                           ->attach(Swift_Attachment::fromPath($attachment));
            });
        }
    }

它不断返回

Symfony \ Component \ Debug \ Exception \ FatalErrorException

Class 'Lib\Services\Mail\Swift_Attachment' not found

我不确定Swiftmailer类的调用位置。

1 个答案:

答案 0 :(得分:2)

你可以\Swift_Attachment::FromPath('FooBar')

在开头添加use Swift_Attachment;