PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
adding images to an html but not attachment

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
erwandrd



Joined: 08 Feb 2008
Posts: 2

PostPosted: Fri Feb 08, 2008 1:46 pm    Post subject: adding images to an html but not attachment Reply with quote

Dear new friends from the Pear Forum world family,

I ain't no expert in using Pear Mail but I'm slowly getting the grips of it but there's one or two little things that are doing my wee little head in.

I want to send html email using Mail_mime and add images to it (who wouldn't?!) and it works!!
My concern is that I don't want these images to appear as attachments as they do at the moment.. although I learned from a tutorial that it shouldn't happen.

Is it possible or am I the victim of a big white lie?

here's my piece of kit:


include('Mail.php');
include('Mail\mime.php');

$message = new Mail_mime();
$text = file_get_contents("mail_folder/mail_text.txt");
$html = file_get_contents("mail_folder/mail_html.html");
$imagem = file_get_contents("mail_folder/R2D2.gif");
$logo = file_get_contents("mail_folder/logo_mail.gif");


$message->setTXTBody($text);
$message->setHTMLBody($html);
$message->addHTMLImage($imagem,"image/jpeg","R2D2.gif",false);
$message->addHTMLImage($logo,"image/gif","logo_mail.gif",false);

$body = $message->get();
$extraheaders = array("From"=>"R1 <[email protected]>", "Subject"=>$_POST[subject]);
$headers = $message->headers($extraheaders);

$mail = Mail::factory("mail");
$mail->send($line[email_addr], $headers, $body);

My second question is: Is this the best way of sending a News letter, knowing that the codes above are used in a while loop for each subscribers.

Thank you for any help.

Ta ra
Back to top
View user's profile Send private message
magnamel



Joined: 22 Aug 2010
Posts: 2

PostPosted: Sun Aug 22, 2010 5:23 pm    Post subject: Reply with quote

I'm new for PEAR and PHP in general
I have the same problem
Anyone have a solution?

Thanks
Back to top
View user's profile Send private message
erwandrd



Joined: 08 Feb 2008
Posts: 2

PostPosted: Sun Aug 22, 2010 10:23 pm    Post subject: Reply with quote

What I've learned after many hours of banging my heads on the wall trying to figure out how to make it work.. is that there's shit loads of free services that you can easily incorporate in your website that will save you a lot of time and trouble..
In my case for the News letter I use mail chimp it's free and easy to use.

to send mail without image attachement just give your IMG tag an external link.

ie: <IMG href="http://www.whatever.yo/images/blabla">

hope this helps
Back to top
View user's profile Send private message
magnamel



Joined: 22 Aug 2010
Posts: 2

PostPosted: Mon Aug 23, 2010 11:52 am    Post subject: Reply with quote

Hi erwandrd,
thank you for reply. I've solved the problem changing my html template.
i don't know because it work well now. The actual template is more simple and not uses CSS.

Bye Luca
Back to top
View user's profile Send private message
peterlembke



Joined: 15 May 2011
Posts: 1
Location: Stockholm, Sweden

PostPosted: Sun May 15, 2011 10:35 pm    Post subject: Reply with quote

You can easily embed images in HTML email.

Use can use this Binary file to BASE64 encoder
http://www.greywyvern.com/code/php/binary2base64

Then paste the base64-encoded image data to a normal IMG-tag:
$test="<img src=data:image/png;base64,yourdatahere>";

PHP have functions for BASE64 encoding/decoding if you want to write your own binary to BASE64 encoder. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement