我试图在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类的调用位置。
答案 0 :(得分:2)
你可以\Swift_Attachment::FromPath('FooBar')
或
在开头添加use Swift_Attachment;