如何将来自公用文件夹的文件附加到邮件? [英] How can I attach file coming from the public folder to Mail?
本文介绍了如何将来自公用文件夹的文件附加到邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想发送一封带有pdf附件的电子邮件,该附件名为资格预审",该电子邮件位于我的公共目录中.我该如何访问?
I want to send an email with a pdf attachment named "pre-qualification" and that is inside my public directory. How can I access that?
这是我存储方法中的内容:
This is what I have in my store method:
Mail::send(new OfferEmailUser($request));
OfferEmailUser看起来像这样:
And the OfferEmailUser looks like this:
public $request;
public function __construct($request)
{
//
$this->request = $request;
$this->to($request->email, $request->name);
$this->subject('Email Notification on offer');
}
public function build()
{
return $this->view('emails.offeremailuser');
}
推荐答案
As jelhan mentioned in their comment, Laravel's mail attachment docs should help here, e.g.
return $this->view('emails.offeremailuser');
成为
return $this->view('emails.offeremailuser')
->attach('/path/to/file');
您可能还想知道如何在公用文件夹中引用文件的路径. Laravel也为此提供了 helper函数.最终结果可能类似于:
You may also be wondering how to reference the path to your file in the public folder. Laravel has a helper function for this too. The final result may look something like:
return $this->view('emails.offeremailuser')
->attach(public_path('pre-qualification.pdf'));
这篇关于如何将来自公用文件夹的文件附加到邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文