这就是我正在尝试做的(使用laravel-medialibrary):
$message = Message::find(50);
$media = $message->getFirstMedia();
//todo can be more than one
$fileName = $media->id . '/' . $media->file_name;
$file = Storage::disk('s3')->get($fileName);
//create mailable
$mail = (new NotificationMail($this->template, new NotificationLog()))
->mailer('smtp')
->from('test@fdsf.co.uk', 'A. Test')
->subject('Any Luck')
->attach($file);
$response = Mail::to('fsdafd@gfdsg.com')->send($mail);尝试过多种方式,但邮件中的附件始终只是文本:
--_=_swift_1601042677_ccb98caa4058cf66bc6face36e70ef0a_=_ Content-Type: application/octet-stream; name="=?utf-8?Q?发布于 2020-09-26 01:49:51
你可以这样试一下
$mail = (new NotificationMail($this->template, new NotificationLog()))
->mailer('smtp')
->from('test@fdsf.co.uk', 'A. Test')
->subject('Any Luck')
->attachFromStorage('/path/to/file', 'name.pdf', ['mime' => 'application/pdf']);或者,您可以将路径附加到电子邮件
$file = Storage::disk('s3')->url($fileName);发布于 2020-09-28 18:10:54
这简直是胡说八道。
attachFromStorage正在工作,但之后邮件被格式化了。
这不知何故将身体设置为空的,从而阻止了附件的工作。
https://stackoverflow.com/questions/64066911
复制相似问题