Need help with a contact form i am using. Have tried everything but i can't get the form to send the message in html (so i can include an image). At the moment the received email will not show the image but instead shows <img src='http:// mysite .com/title.jpg' /> in the email Code is as follows <? $mailto = "contact@ mysite .com"; $cc = ""; $bcc = ""; $subject = "Contact Form"; $vname = "Name"; $email = $_POST['email']; function validateEmail($email) { if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email)) return true; else return false; } if((strlen($_POST['name']) < 1 ) || (strlen($email) < 1 ) || (strlen($_POST['message']) < 1 ) || validateEmail($email) == FALSE){ $emailerror .= 'Error:'; if(strlen($_POST['name']) < 1 ){ $emailerror .= '<li>Enter name</li>'; } if(strlen($email) < 1 ){ $emailerror .= '<li>Enter email</li>'; } if(validateEmail($email) == FALSE) { $emailerror .= '<li>Enter valid email</li>'; } if(strlen($_POST['message']) < 1 ){ $emailerror .= '<li>Enter message</li>'; } } else { $emailerror .= "<span>Your email has been sent successfully!</span>"; $timestamp = date("F j, Y, g:ia"); $messageproper ="\n\n" . // // // THE IMAGE BELOW IS THE ONE I WANT TO BE SENT IN EMAILS, AND BE SEEN ON RECEIVING THE EMAILS // // // "<img src='http://www. mysite .com/title.jpg' />" . "\n" . "Dear Me" . "\n" . "You've received a new message" . "\n" . "\n" . "Name: " . ucwords($_POST['name']) . "\n" . "Email: " . ucwords($email) . "\n" . "Comments: " . $_POST['message'] . "\n" . "Company: " . $_POST['company'] . "\n" . "Telephone Number: " . $_POST['telephone'] . "\n" . "\n\n" ; $messageproper = trim(stripslashes($messageproper)); mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() ); } ?> <div id='emailerror'> <ul> <? echo $emailerror; ?> </ul> </div> Code (markup): +Rep for anyone who can help. Thanks. .
Have you added this lines in your header? $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Code (markup):
<?php //define variables $to = //your email address $subject = //subject $headers = "MIME-Version: 1.0\r\n". "Content-type: text/html; charset=iso-8859-1\r\n". "From: Whoever"; $message = " <html> <body> <img src=\"img src='http:// mysite .com/title.jpg\"border=\"0\" alt=\"\"> </body> </html> "; //Send mail function mail($to,$subject,$message,$headers); echo "Hola! picture sent"; ?> Code (markup):
Thanks Javaongsan, knew it was something simple. Finally got it working +rep Simple as that, can't believe i was stuck with it for so long!