mercredi 13 septembre 2017

Laravel 5: sending multiple mails with the same image embedded causes "Swift_IoException: Unable to open file" error

In Laravel's email, an image becomes inaccessible if it's embedded multiple times.

To clarify the point, here is a piece of the code...

    //For Recipient A
    Mail::send('email', $data, function ($message) use ($emailA) {
        $message->from(env('MAIL_ADDRESS'), env('MAIL_TITLE'));
        $message->to($emailA);
    });

    //For Recipient B
    $data['flag'] = true;
    Mail::send('email', $data, function ($message) use ($emailB) {
        $message->from(env('MAIL_ADDRESS'), 'Title for recipient B');
        $message->to($emailB);
    });

    //In the 'email' view....
    @if(!empty($flag))
    <div>Flag is true</div>
    @endif
    <img src="">

Error message is - Swift_IoException: Unable to open file for reading [http://ift.tt/2waHez2]

Recipient A received the email with the image.jpg, but the email wasn't sent to Recipient B. Because Recipient A gets the email with the image file, the image file itself must be available. Then, why Swift is unable to open it?

Any advice will be appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire