Forum Moderators: coopster

Message Too Old, No Replies

How To Send Mail HTML Using Php Mail Form ?

How To Send Mail HTML Using Php Mail Form?

         

DjZoC

10:51 am on Mar 3, 2009 (gmt 0)

10+ Year Member



i make my script for mail form php and is looking like this

<?php
if(isset($_POST['sendmail'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$to="admin@mywebsite.com";
$from = "From: $email\r\n";
$subject="...";
$body="..";
if(mail($to, $subject, $body, $from)){
echo "Your Email Was Send";
}
}
?>

how i can send html mail ? what i need to add on this script ?

i try $body="<img src="http://www.mywebsite.com/myphoto.jpg" border="0">";

and is give me error :(

and if i add like this
$body="<img src='http://www.mywebsite.com/myphoto.jpg' border='0'>"; and is show me exacly like this no photo :(

can someone help me with this ? just to explain me what i need to add on my php script so i can send html mail from my php form

[edited by: DjZoC at 10:57 am (utc) on Mar. 3, 2009]

rocknbil

4:21 pm on Mar 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



// To send HTML mail, the Content-type header must be set
//Also a FROM field is required or it comes from anonymous.
$headers = "From: $from\r\n"; // Preformat as "company" <email>
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Mail it
mail($to, $email_subj, $emailbody, $headers);

W.O.W., you *really* need to do some filtering on those $_POST variables, your script is currently open to all sorts of attacks and abuse using the input variables directly.

DjZoC

4:59 pm on Mar 3, 2009 (gmt 0)

10+ Year Member



thank you man you save my day ! but what filtering to i use ?

one more think ...
how i can read from .txt ?
i want to make something like

text.txt this is type in .txt :
-----------------------
movie1.php
movie2.php
-----------------------

and to read like this

New Movie : Movie1.php
New Movie : Movie2.php

can someone help me with this please ... thank you !

[edited by: DjZoC at 5:04 pm (utc) on Mar. 3, 2009]