PDA

Click to See Complete Forum and Search --> : PHP to email


GingerNut
Oct 3rd, 2002, 02:18 PM
Hi guys,

I have a set of php scripts which are used for a show/movie database. There is a reservation form which then sends an email to the Box Office. The problem is, the box office uses StarOffice for their email and for some reason, which I don't know, the email is coming through as gobbledygook. Here is the bit of code that sends the email:


function send_email() // sends email
{
global $name_title_, $name_, $address_, $city_, $country_, $zip_, $home_phone_, $work_phone_, $email_, $contact_method_, $contact_method2_, $contact_method3_, $movies_, $number_of_tickets_, $seating_type_, $main_message_, $tickets_, $credit_card_payment_, $price_;
global $qft1_days;


$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$now = date("m/d/Y, D h:i a"); // gets the date/time now

$message=" <html> <head> </head>
<body>
<b><font color=\"#000099\">A NEW RESERVATION</b> <BR>
<b><font color=\"#000099\">$now</b></font><BR>
<BR align=\"left\"><i><b><font color=\"#000099\">Customer's info:</b></i>
<BR align=\"left\"> <font color=\"#000099\"><b>Name:</b></font> $name_title_ $name_
<BR align=\"left\"> <font color=\"#000099\"><b>Address:</b></font> $address_
<BR align=\"left\"> <font color=\"#000099\"><b>City:</b></font> $city_
<BR align=\"left\"> <font color=\"#000099\"><b>County:</b></font> $country_
<BR align=\"left\"> <font color=\"#000099\"><b>Postcode:</b></font> $zip_
<BR align=\"left\"> <font color=\"#000099\"><b>Home Phone:</b></font> $home_phone_
<BR align=\"left\"> <font color=\"#000099\"><b>Work Phone:</b></font> $work_phone_
<BR align=\"left\"> <font color=\"#000099\"><b>E-mail:</b></font> $email_
<BR align=\"left\"> <font color=\"#000099\"><b>Contact method:</b></font> $contact_method_ $contact_method2_ $contact_method3_
<BR align=\"left\"> <font color=\"#000099\"><b>Message:</b></font> $main_message_

<BR><BR align=\"left\"><b><i><font color=\"#000099\">Reservation info:</font></i></b>

<BR align=\"left\"> <font color=\"#000099\"><b>Show:</b></font> $movies_
<BR align=\"left\"> <font color=\"#000099\"><b>Number of tickets </b></font> $number_of_tickets_
<BR align=\"left\"> <font color=\"#000099\"><b>Seats types:</b></font> $seating_type_
<BR align=\"left\"> <font color=\"#000099\"><b>Reservation date:</b></font> $qft1_days



</p>
</body>
</html>";
//ncmillar@btinternet.com
//i_stanev2000@yahoo.com
mail("ncmillar@btinternet.com", "Show Reservation", "$message", $headers); // sends an email
}



Could someone please tell me how to change it so that the information goes as straight text rather than html, so that it can be properly read using StarOffice?

GingerNut
Oct 3rd, 2002, 02:42 PM
It's OK, I think I got it.
I can't test it properly til tomorrow so I may be back. :rolleyes:

MoMad
Oct 3rd, 2002, 02:42 PM
What the hell? You have a html message (ala tables and html tags) and you are not sure why your message is HTML?? Wow... man come on, just change your message = field to be text only... or...

Use a MIME class... I had one somewhere, ill upload it (just change .txt to .php) and use that class:

actually ill point you to the site i downloaded it at:

http://www.phpbuilder.com/columns/kartic20000807.php3

Read the article, understand it, download the class, test it out, do whatever with it, implement it :)

GingerNut
Oct 3rd, 2002, 02:52 PM
Hi MoMad,

The problem was, the script was so bloody long that i couldn't see where the prob was. It was only when I isolated the mail part to post here that I noticed what to do.

MoMad
Oct 3rd, 2002, 03:48 PM
lol.. you should use classes man, goto:

http://www.phpclasses.org

to see some cool classes, i recommend (DB.class.php -- pretty cool and i helped make it better :D)

Also, using classes simplifies everything and minimizes your "mistakes" or "debugging"...