Page 1 of 1

MIME Email

Posted: Sat Nov 16, 2002 12:32 am
by nigel-9SW
I have read a lot, and I mean a lot of details about MIME email but all the examples appear to be very complex. Is there a simple method to take an HTML page and send it as part of an email ?
Cheers one and all

Posted: Sat Nov 16, 2002 12:53 am
by MeOnTheW3
MAIL()

Posted: Sat Nov 16, 2002 1:48 am
by nigel-9SW
Thanks for the help but.....

What I need to know is the header settings and how to deal with multipart and boundaries etc.

Any help on this would be useful

Cheers

Posted: Sat Nov 16, 2002 4:46 am
by skyhawk133
Don't know if you've seen this one yet:

Code: Select all

$headers = "From: dream.in.code <forums@dreamincode.net>\r\n"; 
$headers .= "To: ".$name."<".$email.">\r\n"; 

//specify MIME version 1.0 
$headers .= "MIME-Version: 1.0\r\n";  

//unique boundary 
$boundary = uniqid("HTMLDEMO");  

//tell e-mail client this e-mail contains//alternate versions 
$headers .= "Content-Type: multipart/alternative" .  
   "; boundary = $boundary\r\n\r\n";  

//message to people with clients who don't 
//understand MIME 
$headers .= "This is a MIME encoded message.\r\n\r\n";  

//plain text version of message 
$headers .= "--$boundary\r\n" .  
   "Content-Type: html/text; charset=ISO-8859-1\r\n" .  
   "Content-Transfer-Encoding: base64\r\n\r\n";  
$headers .= chunk_split(base64_encode("$plain"));  

//HTML version of message 
$headers .= "--$boundary\r\n" .  
   "Content-Type: text/html; charset=ISO-8859-1\r\n" .  
   "Content-Transfer-Encoding: base64\r\n\r\n";  
$headers .= chunk_split(base64_encode("$html"));  


//Finally, last but not least... send the email

mail($email, $subject, "", $headers);
$plain and $html are the 2 variables you pass this script that send a plain text and an HTML email, $email is the email addy of the recipient and $subject is the email subject.

I use this on a weekly basis to send out a newsletter to my 2000+ members and it works great. AOL users are pretty much SOL and anyone without an email proggie that supports MIME headers is also SOL, but hey... what would the world be without AOL users and the other folks?!

Posted: Sat Nov 16, 2002 8:56 am
by nigel-9SW
Thanks I will try this.

I have been experimenting with htmlMimeMail from phpguru.org

So far I have built some html emails with backgrounds and multiple images (gifs and jpgs) with success.

My next step is to include some sounds files (midi) that also can be sent with the email. Does anyone know how to do this ?

I have attached the files but this results in the email showing an attachment, the midi does not play automatically.

Posted: Sat Nov 16, 2002 10:30 am
by skyhawk133
Link it from offsite, full http://www..... address

Here is the newsletter I send out with that script:

http://home.dreamincode.net/newsletters/111102.php

Posted: Thu Nov 21, 2002 11:02 am
by unclep
I tried to use the script provided, but I'm having some difficulties. When I check the mail on my Hotmailaccount, everything is OK. When I check mail within my own webmailaccount, which only supports plain text, everything is OK as well.
But when I use Outlook the full headers are printed in my message and I don't get the HTMLmessage I created.

Do I need extra headers for Outlook or something like that?

Problem solved

Posted: Fri Nov 22, 2002 9:31 am
by unclep
I solved the problem myself by deleting \r from the script.

Posted: Sat Nov 23, 2002 11:52 am
by nigel-9SW
Thanks for all the tips.

I have continued to experiment and discovered that the phpguru script works well, excpet the real pain is having to enter all the image refrences from the linked html page.

what I have been seeking is a parsing script to read the linked html, extract all the image links and pass these to the phpguru script before sending email.

The last step is to create a form to handle the selected recipients and the html to send and I will have an automated HTML emailer.

On the sound attachement front I have used a link to the web from within the eamil html, but this does not work ? It does if I open the html directly, but not from within outlook. Any ideas anyone?