HTML in 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
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

HTML in emails?

Post by lazersam »

Hi all,
I am sending a html email using the mail() function. I can do this with no problem except.... when my user inputs the html using a form. Then it doesnt work(?)

My form code is this;

Code: Select all

<head>
<title>Sender</title>
</head>

<body>

<form method="POST"  action= "process_sender.php"   >
  
  <p>Email to:</p>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="278" id="table1">
    <tr>
      <td width="44"><input type="radio" value="all_verified" checked name="radio_but"></td>
      <td>All Verified Subscribers</td>
    </tr>
    <tr>
      <td width="44"><input type="radio" name="radio_but" value="non_verified"></td>
      <td>Non Verified Subscribers</td>
    </tr>
  
  </table>
  
  <p>Subject Line: 
  <input type="text" name="subject_line" size = "26" >
  
  </p>
  
  <p>Paste Email Here....</p>
  <p><textarea rows="7" name="email_text" cols="32"></textarea></p>
  <p><input type="checkbox" name="email_to_self" value="ON"> Send Test to Self!</p>
  <p><input type="submit" value="Send" name="B1"><input type="reset" value="Reset" name="B2"></p>
  <p> </p>
</form>

</body>

</html>
The processor mail function code looks like this...

Code: Select all

<?php

$success=mail($email, $subject_line, $email_text, $headers);

?>
The problem is that when my user pastes the html, the mail() function errors because of the speech marks (")
This does not happen when I paste the html into the script.

Any ideas?

Lawrence
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what does the script at viewtopic.php?t=8815#65245 tell you about your php version and register globals?
Maybe you have to change your script as mentioned in viewtopic.php?t=511
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

Hi Volka

PHP Version: 4.3.3
Display Errors: On
Error Level: Not E_ALL
Register Globals: On

I have used the $_POST function but that did not work.

I am thinking this must be a common problem. A user pastes some html in a form that will be sent as an email - this must be common (?).

Actually, putting the email aspect aside.... the text that is passed via the form is altered by PHP even before it reaches the mail function!

For example, I paste

Code: Select all

<p>If you want to look at the product1
<a href="http://www.centurionpowernetwork.com/PHP/ListBuilder/Products/MiniSites/product1/index.php?s_id=sub_id&aff_id=affiliate_id"
>
CLICK HERE!</a></p>
...but the link is altered by becoming....
I think its got something to do with the (") If I remove the speech marks then the link will come out fine.

Regards

Lawrence.
User avatar
lazersam
Forum Contributor
Posts: 105
Joined: Sat Nov 15, 2003 4:07 am
Location: Hertfordshire, UK

Post by lazersam »

OK I think I have solved it.

The PHP was adding slashes to the text - I use the function stripeslashes() and it seems to work :)

Regards

Lawrence.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Post Reply