Sending HTML via a PHP form, not working out...<

liunx

Guest
Wow, it's been ages since I've posted here.

Anyway, down to business:

I'm making a form that will let banned users from a counter-strike server appeal their ban. I'd also like it the email it sends to look presentable and not just be in plain text. I have an entire page setup for this but it is proving more difficult than I thought. (I will post code below).

What I have is a basic email script and I'm trying to send HTML through the script via a function I created that holds all the HTML. All it is doing however, is outputting the HTML to the browser and sending a blank email to me.

Here are some of the more important snippets of my code thus far:

(the actual send form):

$headers = "From: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->\r\n";
$headers .= "Reply-To: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->\r\n";
$headers .= "Return-Path: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$send_to = "[email protected]";
$subject = "United Gamerz Ban Appeal From $handlex";
$mail_html = email_html ($handlex,$emailx,$steamx,$ipx,$adminx,$reasonx,$appealx);
$form_send = mail($send_to,$subject,$mail_html,$headers);


if ($form_send) {

success();

} else {

err();

}


(here is the HTML function)
(also note, this is not the one I'm sending, it is much more complex, but very much the same format as this. I posted this one to save space)

function success() {

$suc = <<< EOSHWSUC
<table width="379" border="0" cellpadding="0" cellspacing="0" class="brdr">
<tr>
<td height="18" align="center" valign="middle" class="tblhdr">
<div align="center">
<strong>Success!</strong>
</div>
</td>
</tr>
<tr>
<td align="center" valign="middle" class="td">
<p>Your ban appeal has been sent to the UnitedGamerz
admins. You should be hearing from us shortly. Please
be patient.
</p>
</td>
</tr>
</table>
EOSHWSUC;

echo $suc;

}



Like I said above all the script does is output the HTML function to the browser and send an empty email to me. Anythoughts on how to fix this?this could be the cause:

$mail_html = email_html

shouldn't that be $email_html ?No, email_html is the function (like the second example in the code above) that holds the html info I want used in the email.sorry, missed that....

there's a space between the function name and it's parameters...

also, have you tried this out with a simpler html output in the email?ok, if you don't get contents of your email we will need to see the email_html function.

also I tend to do it this way


$headers = "From: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> <[email protected]>\r\nContent-Type: text/html\n";

that is really all you need to send html email.

so what is happening with yours?Ok, here is email_html:


function email_html ($handlex,$emailx,$steamx,$ipx,$adminx,$reasonx,$appealx) {

$email = <<< EOSHWEML
<html>
<head>
<title>UnitedGamerz Ban Appeal</title>
<link href=http://www.htmlforums.com/archive/index.php/"inc/style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#F6F6EB" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center"><br>
<img src=http://www.htmlforums.com/archive/index.php/"ugz_head.gif" width="379" height="78"> <br>
<hr align="center" width="379" noshade>
<br>

<br>
<table width="379" border="0" cellpadding="0" cellspacing="0" class="brdr">
<tr>
<td height="18" align="center" valign="middle" class="tblhdr">
<div align="center">
<strong>A Ban Appeal Has Been Made By: $handlex</strong>
</div>
</td>
</tr>
<tr>
<td align="center" valign="middle" class="td">
<blockquote>
<br>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class="lightborder">
<tr>
<td align="center" valign="middle">User Information</td>
</tr>
</table>
<br>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class="lightborder">
<tr>
<td>
<blockquote>
<strong>Handle: </strong>$handlex<br>
<strong>Email: </strong>$emailx<br>
<strong>Steamid: </strong>$steamx<br>
<strong>IP Address: </strong>$ipx<br>
<strong>Banning Admin:</strong> $adminx<br>
<strong>Reason for ban: </strong>$reasonx<br>
</blockquote>
</td>
</tr>
</table>
<br>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class="lightborder">
<tr>
<td align="center" valign="middle">Ban Appeal</td>
</tr>
</table>
<br>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class="lightborder">
<tr>
<td>
<blockquote>$appealx</blockquote>
</td>
</tr>
</table>
<br>
<br>
</blockquote>
</td>
</tr>
</table>
<br>
<br><a name="banform">
<br>
</div>
</body>
</html>
EOSHWEML;

echo $email;

}


I'll try changing the headers to see if that helps anything.

Also, like I said earlier, the email_html function works properly because when I try to send the mail it outputs to my screen (because of the if statement regarding to $form_send) and returns nothing in the email. Sometimes there is a single "." though.you can't echo the email from the function, you have to return it.

return $email;That worked. Thanks! It was so easy. :)
 
Back
Top