MIME Email
Moderator: General Moderators
MIME Email
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
Cheers one and all
-
skyhawk133
- Forum Newbie
- Posts: 9
- Joined: Wed Nov 13, 2002 10:25 pm
- Location: Rio Rancho, NM
Don't know if you've seen this one yet:
$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?!
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);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?!
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.
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.
-
skyhawk133
- Forum Newbie
- Posts: 9
- Joined: Wed Nov 13, 2002 10:25 pm
- Location: Rio Rancho, NM
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
Here is the newsletter I send out with that script:
http://home.dreamincode.net/newsletters/111102.php
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?
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
I solved the problem myself by deleting \r from the script.
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?
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?