how can i send HTM emails?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
webfinearts
Forum Newbie
Posts: 12
Joined: Tue Sep 30, 2003 12:02 pm
Contact:

how can i send HTM emails?

Post by webfinearts »

I tried to send HTML emails including following lines in the header:

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

But what i receive is a plain text of the email (including the html code).
If is possible please just post also a working email class. I will appreciate that a lot :).
philippgerard
Forum Newbie
Posts: 6
Joined: Tue Sep 30, 2003 1:17 pm
Contact:

Post by philippgerard »

Code: Select all

<?php
$message = "<h1>Hello world!<h1>";
$to      = "empfaenger@system.de";
$subject = "Betrefftext";
$xtra    = "From: ab@sender.de (Ab Sender)\r\n";
$xtra   .= "Content-Type: text/html\r\nContent-Transfer-Encoding: 8bit\r\n";
$xtra   .= "X-Mailer: PHP ". phpversion();

mail($to,
     $subject,
     $message,
     $xtra);

?>
User avatar
webfinearts
Forum Newbie
Posts: 12
Joined: Tue Sep 30, 2003 12:02 pm
Contact:

Post by webfinearts »

Can you explain me that encoding line?
User avatar
webfinearts
Forum Newbie
Posts: 12
Joined: Tue Sep 30, 2003 12:02 pm
Contact:

Post by webfinearts »

Look what he gave me:

Content-Type: text/html
Content-Transfer-Encoding: 8bit
From: Birthday Reminder <birthday@example.com>



<html>
<head>
and here the html code
User avatar
webfinearts
Forum Newbie
Posts: 12
Joined: Tue Sep 30, 2003 12:02 pm
Contact:

Post by webfinearts »

Is displayng me every time this line:
Content-Transfer-Encoding: 8bit X-Mailer: PHP 4.2.2

My problem is that i do not know what's happening :(. Damn i'm a great newbie
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

ehm, i suppose you didn't switch off the ability to receive e-mails in HTML-format in your mail-programm, did you?
That would be my newbie-mistake ! 8O

Edit: The script from philippgerard seems to work for me.
philippgerard
Forum Newbie
Posts: 6
Joined: Tue Sep 30, 2003 1:17 pm
Contact:

Post by philippgerard »

sure it does ;-)

I only post wrong code when asking you guzs to find my bugs ;-)

guess your mailprog sucks. allow it to display html should work.
User avatar
webfinearts
Forum Newbie
Posts: 12
Joined: Tue Sep 30, 2003 12:02 pm
Contact:

Post by webfinearts »

hm no
Because eerything seems to be ok now, only that line.
The funny thing is that if i'm deleting it the next line above that is displayed.
jayr517
Forum Commoner
Posts: 26
Joined: Fri Aug 22, 2003 7:28 pm
Location: Boise, ID
Contact:

Post by jayr517 »

The funny thing is that if i'm deleting it the next line above that is displayed.
Can you post the code you're having a problem with? I know philip posted the code you're using, but sometimes a syntax or logic error can sneak in while you're formatting, modifying, deleting etc, etc, etc...
Post Reply