0

Using phpmailer I need to build an email with an embedded image which has a link.
At the body of the message it is trivial to include

<a href="link"><img src="URL of the image to embed" /></a>

My problem is that that URL is protected by username and password so the recipient of the email cannot see the image, just a broken thumbnail with the link.
I tried using file_get_contents() as I read in other questions but didn't get the solution.

dstonek
  • 867
  • 1
  • 17
  • 28
  • You could place the image in another folder outside the public area and echo it from an include or similar; could work. – Funk Forty Niner Jan 06 '19 at 15:48
  • Possible duplicate of [How can i attach an image using Phpmailer?](https://stackoverflow.com/questions/6095285/how-can-i-attach-an-image-using-phpmailer) – rickdenhaan Jan 06 '19 at 16:24
  • @FunkFortyNiner I already bought that but it is not the idea. – dstonek Jan 06 '19 at 16:48
  • @rickdenhaan $mail->AddEmbeddedImage ASFAIK it is not possible to add a hyperlink and also I cannot place the image in the right place of the body of the message – dstonek Jan 06 '19 at 16:51
  • 1
    @dstonek yes it is, see the accepted answer on that question. First call `AddEmbeddedImage` with the path to the file and give it an identifier via the second argument. Then you can add an `` to your message body wherever you want it, where `foo` should match the identifier you provided to `AddEmbeddedImage`. That `` *can* be inside an `` tag. – rickdenhaan Jan 06 '19 at 18:38
  • This was enough to get it. `$mail->AddEmbeddedImage(“/path/to/image/“,”img”);` `Text
    – dstonek Jan 07 '19 at 12:09

0 Answers0