attaching an existing pdf file to an empty email, no longer shows the attachment. Mailtrap will show it as raw text with no attachment, apple mail shows nothing.
Putting anything in the email view will allow the attachment. However this conflicts with the api of some email fax services which need an empty email with a pdf attachment. This worked as of 5.5.37
Controller:
// token is just a field to secure a private file on a public drive for the few seconds this file is available and has no bearing.
Mail::to($email)->send(new EmailPdfAttachment($this->token,$this->subject));
Laravel 5.6 mailable EmailPdfAttachment.php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class EmailPdfAttachment extends Mailable
{
use Queueable, SerializesModels;
public $token;
public $subject;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($token,$subject)
{
$this->token = $token;
$this->subject = $subject;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.empty.single')
->attach('storage/'.$this->token.'/output.pdf',['mime' => 'application/pdf'])
->subject($this->subject);
}
}
View emails/empty/single.blade.php
// this was just an empty file, which worked perfectly in 5.5.37, after a half a day i added the
// follwing text and now it works, but it has the text attach a pdf.
attach a pdf
Here is screen shot from email

It's too clever and whitespace won't fool it.
The same code will run in laravel 5.5.x
Cheers,
please let me know if there is anything else I can do to help fix this.
I think Laravel is using Swiftmailer for sending emails, maybe test a couple of versions of swiftmailer if it triggers the same error?
Sure, I’ll look into it, the only change on our end was the shift from laravel 5.5 to 5.6 but I’m sure that many of the dependency versions were bumped. I’ll restore an older version to check. But if there is a way to make it work with the current technology stack that’s always preferable.
Sent from my iPhone
On Mar 17, 2018, at 4:10 PM, M. Vugteveen notifications@github.com wrote:
I think Laravel is using Swiftmailer for sending emails, maybe test a couple of versions of swiftmailer if it triggers the same error?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I just experienced this same issue.
I had been using mandrill and attaching PDFs successfully in v5.5 and just upgraded to 5.6 yesterday.
I have a view that I use as a dummy view so that the mailable will send without any errors — my actual templates are in MailChimp and set via the X-MC-Template header.
I added just an HTML comment to my dummy view and attachments now work as expected.
Thanks for the comment, I’d like to go back and test that, I know the single character in my case was being parsed by the external service and I ended up just downgrading to not add hours to the project. But that’s seems like a great idea!
Hmm I see your point but you could argue that this is standard behavior and you would have to be explicit about any content you place in the email. Since this is more a behavioral change if we would have to add some sort of dummy comment if an email was empty I suggest to open up an issue at the laravel/ideas repository to get support for your idea. After that you may send a PR to the framework.
Most helpful comment
I just experienced this same issue.
I had been using mandrill and attaching PDFs successfully in v5.5 and just upgraded to 5.6 yesterday.
I have a view that I use as a dummy view so that the mailable will send without any errors — my actual templates are in MailChimp and set via the
X-MC-Templateheader.I added just an HTML comment to my dummy view and attachments now work as expected.