hello,
i tried with below code but its not working for me.
I am send it to gmail.

is there anything which i have missed out?

$subject = "Happy Work Anniversary !" ;
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$link = public_path() . "/images/Work_Anniversary.png" ;
$comment = View::make('EmailNotifications/BirthdayEmail');
mail("abc@gmail.com", $subject, $comment, $headers);

and in view i have used

<html>
<body>
Hello <?php echo $employee_name; ?>,<br>
<img src='<?php echo $link?>'>
<br>
path used is <? echo $link ?>
<br><br>
<br><br>Thanks,<br>
GS Lab
<br><br>
</body>

</html>

in gmail, it shows broken link.

Recommended Answers

All 8 Replies

I tried,
but it gives very diffrent path.
it is of something google's

it gived me "/var/www/ABCD/public/" and i have attached "/images/abc.png"
with is nothing but whole path where my image file is located.

In addition, if you're using Laravel, then you can use the asset() helper:

$link = asset("/images/Work_Anniversary.png");

This will prepend the application url.

Hello cereal,
You are right, am using laravel!

I also tried with your solution

<body>
Hello <?php echo $employee_name; ?>,<br>
<img src='<?php echo $link;?>'>
path used is <? echo $link ?>
</body>

path used gives me proper path of local host.
but image is not iserting in email.

what are the other changes which am missing?

You cannot access localhost from outside, because it always points to the machine it's on. You can only make this work if the image is on an accessible server, either by IP address or by domain name.

The other way would be to embed the image into the e-mail, for that I suggest you search the forum. There are examples to be found.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.