Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uloncl's avatar

embedding an image in an email, getting Call to a member function embed() on string

so in my controller i have this

Mail::to('correct email')->send(new BookingUpdate($request->email_content));            
return new BookingUpdate($request->email_content);

so that i can see the email in my browser as an actual email

in my env i have this not including my login

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=null

Booking Update just has this

public $message_text;
public function __construct(String $message_text) {
    $this->message_text = $message_text;
}
public function build() {
    return $this->markdown('emails.booking-update', [
         'message' => $this->message_text
     ]);
}

just to send the text which includes some html sometimes to the email view

and then my email view has this to display it

<div style="width:100%; background-color: #dbdbdb">
    <div style="padding-left: 10%; padding-right: 10%; padding-top: 5%; padding-bottom: 5%; text-align: center">
        <div style="padding: 2rem;text-align: center; background-color: #ffffff; border-radius: .375rem;">
            {{-- {{ dump($message) }} --}}
            <img src="{{ $message->embed(public_path().'/img/logo.png') }}">
            {!! $message_text !!}
        </div>
    </div>
</div>

(dump() returns basically the same thing as $message_text but theres non of the normal styleing that dump() normally has)

and that works without the image i recieve it on my phone and stuff but when i try to do anmything more than just text it breaks, i want to have the logo at the top of the email but i just keep getting Call to a member function embed() on string error

when i use ![Alt text](/path/to/img.jpg) it just displays that code as text at the top

when i tried to use something similar to this in the docs it gave me a similar error to the one im getting now

->attachData($this->pdf, 'name.pdf', [
    'mime' => 'application/pdf',
]);
0 likes
0 replies

Please or to participate in this conversation.