Forum Moderators: coopster

Message Too Old, No Replies

html mail

php`s mail() function

         

kadnan

7:54 am on Jan 17, 2003 (gmt 0)

10+ Year Member



Hi there
i am making a newsletter software in which i have to give both plain text and html option
when i try to send html its not rendring it properly
for example

<table width="100%" color="Red">
mail() converting " to &qoute ,thats why its showing table color black plus not 100% width
what should i do to send exact html code? because I can`t bind admin to send html without double qoutes that is "
thankyou

andreasfriedrich

9:48 am on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It´s not the mail [php.net] function that replaces double quotes with their HTML entities.

mail('af@localhost', 'subject', 
'<script type="text/javascript">alert()</script>');

worked just fine. Make sure that the message does not contain the entities when you pass it to mail().

Andreas

kadnan

12:30 pm on Jan 17, 2003 (gmt 0)

10+ Year Member



yeah but when will you use headers

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

it converts " to &qoutes

-i want to sent html mail not plain text

andreasfriedrich

1:10 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no difference whether you pass extra headers to mail() or not.

Return-Path: <apache@domain.de> 
Received: (from apache@localhost)
by domain.de (8.11.6/8.11.0) id h0HCrDZ02214;
Fri, 17 Jan 2003 13:53:13 +0100
Date: Fri, 17 Jan 2003 13:53:13 +0100
From: Apache <apache@domain.de>
Message-Id: <200301171253.h0HCrDZ02214@domain.de>
To: af@domain.de
Subject: subject
Content-type: text/html; charset=iso-8859-1
.
.
<script type="text/javascript">alert()</script>

Are you sure that mail is working fine without the content-type header field and just converts quotes to entities when you use the extra header field?

If that were the case then I´d consider that a bug in the mail() function. There is absolutely nothing in the documentation that would suggest such a conversion. mail() does not scan the additional_headers to find out the specified content type nor does it convert the message to be of the appropriate type.

Andreas

Tapolyai

1:15 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe you need to escape the " with \, i.e. \", or just the opposite, you need to remove the escape. try running the string through AddSlashes or maybe you are using htmlspecialchars?

kadnan

1:34 pm on Jan 17, 2003 (gmt 0)

10+ Year Member



<td width="50%">ADDD</td>
converts into
<td width="\&quot;50%\&quot;">ADDD</td>

i am not using htmlspecial characters at all

do i need to check something in php.ini?

Tapolyai

1:38 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you post the complete line of code that generates the string? That is, $s_x = 'blah "50%" blah';

kadnan

3:01 pm on Jan 17, 2003 (gmt 0)

10+ Year Member



$message=$contents;

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "From: ADmin <admin@site.com>\r\n";
//$message=htmlentities($message,ENT_NOQUOTES);
/* and now mail it */
mail($to, $subject, $message, $headers)or die ("coudn`t send mail");

andreasfriedrich

3:22 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your code works just fine for me.

Are you sure that the double quotes are ok before you mail the message?

Can you post the complete line of code that generates the string?

Andreas

kadnan

3:27 pm on Jan 17, 2003 (gmt 0)

10+ Year Member



yes i am 100% sure

is there something related to magic qoutes?

did u try to send some html like <font color="Red">Hi</font>

does it work fine for you?

andreasfriedrich

3:36 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did send HTML containg quoted attributes and it worked fine.

magic_quotes_gpc [php.net] sets whether Get/Post/Cookie operations are automatically quoted. magic_quotes_runtime [php.net] does the same for operations that return data from any sort of external source.

Both do not apply in this case. They are about quoting certain characters. They never cause PHP to convert quotes to entities.

Andreas

kadnan

3:43 pm on Jan 17, 2003 (gmt 0)

10+ Year Member



please try some html code and let me know
or should i try imap functions?

andreasfriedrich

4:35 pm on Jan 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you wrote
please try some html code and let me know

i wrote

I did send HTML containg quoted attributes and it worked fine.

IMAP will not really help when you want to send the messages.

Are you running a *nix system or windows?

kadnan

7:54 pm on Jan 17, 2003 (gmt 0)

10+ Year Member



i am sorry guys to bother you
there was nothing wrong in mail()

actualy when u post some html stuff from a form like <font color="Red">
php adds \(slashes)
i just used stripshlashes() and it worked fine

thank you all