Mail_Mime::addAttachment() (Previous) (Next) Mail_Mime::get()

View this page in Last updated: Mon, 02 Jul 2007
English | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Plain HTML

Mail_Mime::addHTMLImage()

Mail_Mime::addHTMLImage() -- add image to message

Opis

If sending an HTML message with embedded images, use this function to add the image.

Parametr

  • string $file - The image file name or the image data itself

  • string $c_type - The content type of the image or file.

  • string $name - The filename of the image. Only used, if $file contains the image data.

  • boolean $isfile - Whether $file is a filename or not.

Zwracana wartość

boolean - Zwraca TRUE w przypadku powodzenia, PEAR_Error w przypadku niepowodzenia.

Uwagi

Ta funkcja nie może być wywołana statycznie.

Mail_Mime::addAttachment() (Previous) (Next) Mail_Mime::get()

Download Documentation Last updated: Mon, 02 Jul 2007
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: Lawrence
Re: Joseph's and jlang's notes about the filename -- I believe you just have to use the *same* full filename in both your HTML and in the call to addHTMLImage(). If you pass a relative path to addHTMLImage(), you need to use the relative path as the URL in the HTML. I.e.:

----
$mime->addHTMLImage("../../img_dir/butterfly.gif");
----
<img src="../../img_dir/butterfly.gif">
----

If you pass a full path to addHTMLImage(), you need to use the full path in your HTML:

----
$mime->addHTMLImage("/home/lawrence/img_dir/butterfly.gif");
----
<img src="/home/lawrence/img_dir/butterfly.gif">
----
Note by: lech.jonczyk@gmail.com
This is how it worked for me:

In the code:

$mime = new Mail_mime($crlf);
$mime->addHTMLimage('mail_templates/img/bg.png', 'image/png');

In the html part of mail body:

<img src="mail_templates/img/bg.png"/>

Cheers
Note by: nwalter@easymailing.eu
How can i get Mime_mail to replace my HTML-Image-Tags by CID strings?
Note by: Joseph@ppool.de
Post #1 is wrong for me it is exactly the opposit:
You must not use an absolute system path but must flatten the file name in the SRC="" tag to contain no folder names or slashes.
Note by: jlang
If you want to add inline images and reference them in your HTML you must use the fully qualified system path.

That means year image should look like this:
<img src="/home/public_html/image.gif">
not
<img src="image.gif">

Mail_Mime will replace your src with the appropriate CID value
Note by: info@roxlu.com
I found out that when you are adding html images inline you need to make sure what kind of transport you use. When using the default "mail" function my images weren't shown in some clients. When I switched to "smtp" everything worked perfectly