1,105,375 Community Members

Sending HTML mails through php

Member Avatar
Albert Pinto
Junior Poster in Training
69 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
pritaeas
mod_pritaeas
11,294 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 
Question Answered as of 2 Years Ago by pritaeas
Member Avatar
Albert Pinto
Junior Poster in Training
69 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Regards.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article