Home > Blockchain >  Changing content type of mail in Laravel 9
Changing content type of mail in Laravel 9

Time:08-11

I am trying to send calendar emails through Laravel, I had this working on Laravel 7 with the below code but, on Laravel 9 setContentType has been removed and setbody has been changed to html or text (meaning you can't set the body content type to text/calendar).

I know the ics file is fine as this has not changed and is also an attachment that and that works.

Is there a way to do this?

Mail::send([], [], function ($message) use ($file, $entitySubject, $entityDesc, $custEmail, $userEmail, $userFullName) {
    $message->subject($entitySubject)->from($userEmail, $userFullName)->attach($file, [
            'as'   => $file->getClientOriginalName(),
            'mime' => "text/calendar",
        ]
    );
    $message->To($custEmail);
    $message->setContentType("text/calendar");
    $message->replyTo($userEmail, $userFullName);
    $message->setbody(file_get_contents($file), "text/calendar; charset='utf-8'; method=REQUEST");
});

CodePudding user response:

Ended up using PHPMailer instead as I couldn't find any way to use the Laravel 9 built in mailer.

  • Related