We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,259 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Sending HTML mails through php

Hi All....

Actually I wanted to send mail through mail function in php...

The mail is sent successfully and I'm receiving it in the inbox...

Problem is I want the mail content in HTML format not plain text.

I've tried this code, but it doesn't seem to work...

<?php

/* =============   Sending Mail, This is a php file which runs when User fills a form and clicks submit, the form data are collected in those variables below   ============== */



$name= $_REQUEST['name'];
$email= $_REQUEST['email'];
$city= $_REQUEST['city'];
$state= $_REQUEST['state'];
$country= $_REQUEST['country'];
$phone= $_REQUEST['phone'];
$profession= $_REQUEST['profession'];
$message= $_REQUEST['message'];


$message1 = '<html><body>';

$message1 .= '<table style="border-color: #666;" cellpadding="10">';
$message1 .= "<tr><td><strong>Name:</strong> </td><td>" . $_POST['name'] . "</td></tr>";
$message1 .= "<tr><td><strong>Email:</strong> </td><td>" . $_POST['email'] . "</td></tr>";
$message1 .= "<tr><td><strong>City:</strong> </td><td>" . $_POST['city'] . "</td></tr>";
$message1 .= "<tr><td><strong>State:</strong> </td><td>" . $_POST['state'] . "</td></tr>";
$message1 .= "<tr><td><strong>Message:</strong> </td><td>" . $_POST['message'] . "</td></tr>";

$message1 .= '</table>';
$message1 .= '</body></html>';




$to= "yogeshnaik6686@gmail.com";



$subject= "Student Data";
$email= $_REQUEST['email'];

$headers="From: $email";
$sent=mail($to,$subject,$message1,$headers);

if($sent)
{
echo "Data Sent Successfully";
}
else
{
echo "Error Sending Data.";
}


?>

Problem is I'm getting the mail, but along with the data all <html> tags are also present.........

Is there any way to show only data in proper html tabular form.....

I think Problem is somewhere in the red marked region........But don't know where exactly it is :-O ..........


Regards

2
Contributors
2
Replies
52 Minutes
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
Albert Pinto
Junior Poster in Training
58 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
pritaeas
Posting Prodigy
Moderator
9,309 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
Question Answered as of 1 Year Ago by pritaeas

Thanx Sir, Yes it did worked.......:icon_mrgreen:

Regards.

Albert Pinto
Junior Poster in Training
58 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0643 seconds using 2.68MB