Skip to content

Instantly share code, notes, and snippets.

@DominikStyp
Created January 26, 2022 13:53
Show Gist options
  • Save DominikStyp/4b309d5104c51a9434db463db9fe1e4d to your computer and use it in GitHub Desktop.
Save DominikStyp/4b309d5104c51a9434db463db9fe1e4d to your computer and use it in GitHub Desktop.
Laravel 7: Embedding images in emails (wors for Gmail too)
<img
src="{{ $message->embed( public_path('images/my-logo.png') ) }}"
alt="{{ env('APP_FRONT_URL') }}" />
@DominikStyp
Copy link
Author

Laravel Inline Attachments make it possible to embed image using $message variable inside Blade view. This approach
As we can see in the email source, image is treated as attachment to the source

Content-Type: image/png; name=my-logo.png
Content-Transfer-Encoding: base64
Content-ID: <2333deaf6d333461b3395b3f5cc203d8@swift.generated>
Content-Disposition: inline; filename=my-logo.png

and the image is converted to:

<img
src=3D"cid:2333deaf6d333461b3395b3f5cc203d8@swift.generated"
alt=3D"http://my.site.com" /> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment