473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sending email from form - can't get html though

I am trying to send and email from a form using php. I got that to work.
The problem is that when I receve the email it is a text version with all the html tags showing.

looks like this:
Expand|Select|Wrap|Line Numbers
  1. <HTML><HEAD><TITLE></TITLE></HEAD><BODY><table width="440" border="1" cellspacing="0" cellpadding="3"><tr><td colspan="2"><em>The following was receved from the General Estimate form</em></td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>I am interested in these type(s) of relocation:</strong></td></tr><tr><td colspan="2"><ul><li>Commercial</li><li>International</li></ul></td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>Contact Info:</strong></td></tr><tr><td>Name</td> <td>jason</td></tr><tr><td>Company Name</td> <td>questfore</td></tr><tr><td>Phone Number</td> <td>234-567-8907</td></tr><tr><td>Best Time to Contact</td> <td>Morning</td></tr><tr><td>Email</td> <td>jasons@questfore.com</td></tr><tr><td>City</td> <td>pittsburgh</td></tr><tr><td>State</td> <td>pa</td></tr><tr><td>Zip</td> <td>15203</td></tr><tr><td>Country</td> <td>use</td></tr><tr><td>DesCity</td> <td>imperial</td></tr><tr><td>DesState</td!
  2. > <td>pa</td></tr><tr><td>DesZip</td> <td>15126</td></tr><tr><td 
  3. > colspan="2" style="background-color:#2362ac; 
  4. > color:#FFFFFF;"><strong>Special 
  5. > Circumstances:</strong></td></tr><tr><td>PackSrv</td> 
  6. > <td>yes</td></tr><tr><td>Storage</td> <td>no</td></tr><tr><td 
  7. > colspan="2" style="background-color:#2362ac; 
  8. > color:#FFFFFF;"><strong>How did you hear about 
  9. > Weleski?:</strong></td></tr><tr><td 
  10. > colspan="2"><ul><li>Television</li><li>Invite</li><li>Web</li><li>&nbs
  11. > p;</li></ul></td></tr></table></BODY></HTML>
should look like this: (tags shouldn't be showing only a table with all data)
Expand|Select|Wrap|Line Numbers
  1. <table width="440" border="1" cellspacing="0" cellpadding="3"><tr><td colspan="2"><em>The following was receved from the General Estimate form</em></td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>I am interested in these type(s) of relocation:</strong></td></tr><tr><td colspan="2"><ul><li>Commercial</li><li>International</li></ul></td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>Contact Info:</strong></td></tr><tr><td>Name</td> <td>jason</td></tr><tr><td>Company Name</td> <td>questfore</td></tr><tr><td>Phone Number</td> <td>234-567-8907</td></tr><tr><td>Best Time to Contact</td> <td>Morning</td></tr><tr><td>Email</td> <td>jasons@questfore.com</td></tr><tr><td>City</td> <td>pittsburgh</td></tr><tr><td>State</td> <td>pa</td></tr><tr><td>Zip</td> <td>15203</td></tr><tr><td>Country</td> <td>use</td></tr><tr><td>DesCity</td> <td>imperial</td></tr><tr><td>DesState</td> <td>pa</td></tr><tr><td>DesZip</td> <td>15126</td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>Special Circumstances:</strong></td></tr><tr><td>PackSrv</td> <td>yes</td></tr><tr><td>Storage</td> <td>no</td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>How did you hear about Weleski?:</strong></td></tr><tr><td colspan="2"><ul><li>Television</li><li>Invite</li><li>Web</li><li>&nbsp;</li></ul></td></tr></table>
Please help, I think it has something to do with the header data but I don't know what to put.

Thanks
- Jason
Jul 24 '07 #1
5 1951
pbmods
5,821 Expert 4TB
Heya, Jason.

To send an HTML Email, you need to set a couple of headers.

Check out this example.
Jul 24 '07 #2
Thanks for the link. I inserted the code for the header and still no luck.
Could it be a php security thing?

here us the code i am using:

[PHP]
$cancelSubmission = false;
if(!isset($_POST['formName'])){exit('Error: no form name found!');}
//if(!isset($_POST['submit'])) {exit('Error: submit was not pushed!');}

//This value defines the subject
$strSubject = "Message from the website - form: " . $_POST['formName'];

//This value defines the sender and receiver email addresses
$strSender = "" //where the email is from (probaly don't need this, it's automaticly generated by the server)
$strReceiver = "" //my email address

//This value defines the re-direction of the browser after submission
$strRedirectURL = 'acknowledgement.htm';

//This value defines body of the email

//a bunch of code that cleans up the form data for the client
//it creates the muli-dimentional array used below

//Create table with titles for each section
$strMessage = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>";

if($fArrayMulti[0][1] == "general_est" ){

//a bunch of code that makes the table
}
//Check to make sure email is not garbage
if(($fArrayMulti[$part[0]][1] == '&nbsp;' || $fArrayMulti[$part[0]][1] == '') && ($fArrayMulti[$part[0]+2][1] == '&nbsp;' || $fArrayMulti[$part[0]+2][1] == '')){
$cancelSubmission = true;
}



//Compile mail and send it

//if(cancelSubmission != true){
//add header
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

if(mail($strReceiver, $strSubject, $strMessage, $header)){
echo "Mail Sent.";
}else{
echo "Error sending email! Message not sent!";
}

//JS_redirect( $strRedirectURL );

//}else{
//JS_redirect("../../home.htm");
//print("Submission canceled");
//}[/PHP]
Jul 24 '07 #3
pbmods
5,821 Expert 4TB
Heya, Jason.

When you send the mail, you use $header instead of $headers. Is this intentional?
Jul 24 '07 #4
YOUR a freakn genius!

and i feel retarded...

I must have copied code a while ago and never changed it in the mail() function
Thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

-Jason
Jul 24 '07 #5
pbmods
5,821 Expert 4TB
Heya, Jason.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Jul 24 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: bojanraic | last post by:
Hi! I recently started playing with Python CGI, and I was happy that my basic input-name--print-hello-name CGI form example worked, so I thought I should advance to somew\hat more complicated...
5
by: BaWork | last post by:
I have a web form where a client can select which site members to send an email to. This form is populated from the contents of the member table, so the form can have 0-x names listed on it...
1
by: Zaidan | last post by:
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA code (I will consider using javascript if I have to) that does the following, at the user command: 1- Start MS Explorer and...
7
by: Marcin | last post by:
Hello all! A few years ago I created a form with button which let me send an email with an attachment. It was created in Access 97. Now I would like to move this application into Access 2003....
2
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name)...
2
by: Oltmans | last post by:
Hi All, I'm trying to send an HTML email from my asp.net 2.0 application. I want to show an "alert" message when user opens up my email message using JavaScript. Though I've been able to send...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
2
by: lstanikmas | last post by:
Hi, I'm validating a form with this ASP but receiving some blank email responses; does anyone see anything wrong with it?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars...
5
by: wktarin | last post by:
Hi. I'm a relative newcomer to the world of php, and I keep bumping into a problem with a mail () form. I need to send an automatic email to two addresses, but I can't seem to get it to work. One...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.