Support the ongoing development of Laravel.io →
Input Views Mail

I am writing a newsletter system for my client. They write the email body with CKEditor and I want to embed all images they give in the editor.

It forwards the content of the email in a variable, named content.

public function send ( $newsletter, $subscriber, $time = 0 )
{
    $template = 'emails.templates.' . $newsletter->template;

    Mail::later($time, $template,
    [
        'content' => $newsletter->content
    ],
    function ($message) use ($newsletter, $subscriber) {
        $message->subject($newsletter->subject);
        $message->from('newsletter@example.com', 'Example Newsletter');
        $message->to($subscriber->email, $subscriber->fullname);

        foreach ( $newsletter->attachments AS $attachment ) {
            $path = public_path($attachment->path); 
            $message->attach($path);
        }
    });

    return Redirect::back()->with('success', true);
}
Last updated 2 years ago.
0

@astroanu

I've seen that of course (even if I'm using Laravel 4.2), but the problem here is I get something like below and I want to process all imgs to be embedded.

<p>This is the first newsletter for you!</p>
<img src="/uploads/first.png" />
<p> Blabla... </p>
0

@balintant

The thread is a bit old, but I am currently facing the same problem. How did you manage to embed the images?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

balintant balintant Joined 2 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.