Skip to content

Mail with attachment CSV = bad content-type #29847

Closed
@yvestan

Description

  • Laravel Version: 5.8.31
  • PHP Version: 7.2.21
  • Database Driver & Version: PostgreSQL

Description:

Hello,

I send specific email : plain text, with body totally empty and CSV file on attachment

    public function build()
    {

        return $this->from(env('MAIL_SENDER'))
                    ->bcc(str_replace('@', '+send@', env('MAIL_SENDER')))
                    ->subject($this->cmd_acces->filename)
                    ->text('emails.admin.ftth.cmd_acces.cmd_acces_mailer') // empty blade file
                    ->attach($this->cmd_acces->csvfile, [
                        'as' => $this->cmd_acces->filename,
                        'mime' => 'text/csv',
                    ]);

    }

No problem with Laravel 5.5 but i've just upgraded to Laravel 5.8 and there's a little bug :

The content-type should by "multipart/mixed" but it is now "plain/text"

Laravel 5.5 => OK

Capture du 2019-09-03 17-38-29

Laravel 5.8 => NOK => bad content-type and base64 on body message

Capture du 2019-09-03 17-39-23

I've change Illuminate/Mail/Mailer.php (https://github.com/laravel/framework/blob/6.x/src/Illuminate/Mail/Mailer.php#L332) and that's work fine

Actual

$message->$method($this->renderView($plain, $data), 'text/plain');

My change : just deleted "text/plain" parameter

$message->$method($this->renderView($plain, $data));

I suppose a bug ?

Steps To Reproduce:

send email : plain text, with body totally empty and CSV file on attachment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions