Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The body of "Symfony\Component\Mime\Part\TextPart" Error While Sending Mail #284

Open
kiranrs opened this issue Jul 21, 2023 · 2 comments
Open

Comments

@kiranrs
Copy link

kiranrs commented Jul 21, 2023

Hi,
I'm facing this error after upgrading Laravel 8.65 to 9.52. It was working fine on Laravel 8 but afterupgrading to Laravel 9I'm getting this error.
The body of "Symfony\Component\Mime\Part\TextPart" must be a string, a resource, or an instance of "Symfony\Component\Mime\Part\File" (got "Illuminate\Support\HtmlString").

This my HTML Code
{!!$message->embedData(QrCode::size(200)->format('png')->generate('My Data'), 'QrCode.png', 'image/png')!!}

@palmersoft-uk
Copy link

palmersoft-uk commented Sep 9, 2023

I experienced the same issue, resolved by using the following code instead

<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(100)->generate('My Data')) !!} ">

@chinleung
Copy link

You need to convert the instance of HtmlString into string. I believe the return type of embedData has changed since the writing of the docs.

You can use something like this:

{!!$message->embedData(QrCode::size(200)->format('png')->generate('MyData')->toHtml(),'QrCode.png','image/png')!!}

I've added the ->toHtml() which will convert the HtmlString instance into string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants