Jump to content


Photo

php error


  • Please log in to reply
10 replies to this topic

#1 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 03 October 2006 - 05:23 AM

Hi, I'm new to the whole php world but I have a script that I'm having trouble with.

I have a website with a contact form and I tested to see if the form would actually send the submitted info to my email but I get this error...

Warning: mail(): Bad parameters to mail() function, mail not sent. in /home/content/g/o/l/goldenhills/html/email_us.php on line 62

Here's the php code:

<?php include  "header.php"; ?>











<table width="1000" border=0 align="center" cellpadding=5 cellspacing=0>

  <tr>

    <td width=150 background="images/bg_pix.jpg"></td>

    <td width=600 bgcolor=#FFFFFF>

      <?php

// multiple recipients

$to  = get_db_setting('email_from') . "\r\n"; // note the comma

// subject

$subject = $_POST['subject'];



// message

//echo "$data[0]";

$message = $_POST['message'];
//$message = get_db_setting('email_text');


// To send HTML mail, the Content-type header must be set
// andy: NOT HTML email
//$headers  = 'MIME-Version: 1.0' . "\r\n";

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



// Additional headers

//$headers .= 'To: <$to>' . "\r\n";

$headers .= 'From: ' . $_POST['emailFrom'] . "\r\n";

// Mail it

mail($to, $subject, $message, $headers);

?>

      <h2>Thanks!</h2>

      Email has been sent to: <br> <?php echo nl2br($to); ?> <br> <br> <br> <br> </H2>

    </td>

    <td width=150 background="images/bg_pix.jpg"></td>

</tr>

</table>

<body>

<?php include "footer.php"; ?>

#2 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 03 October 2006 - 05:33 AM

Can you try doing a test without the from and see if that works?

#3 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 03 October 2006 - 05:35 AM

Can you be more specific? Like I said, I'm really new to php. The only way I'm testing it is from the webpage and I keep getting that error.

#4 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 03 October 2006 - 05:42 AM

Replace:
mail($to, $subject, $message, $headers);
With:

mail($to, $subject, $message);

#5 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 03 October 2006 - 05:50 AM

That didn't work. Same error.

Warning: mail(): Bad parameters to mail() function, mail not sent. in /home/content/g/o/l/goldenhills/html/email_us.php on line 62

#6 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 03 October 2006 - 05:53 AM

Can you check to see that $to is a valid email address? 

echo $to;

Let me know what it says.

#7 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 03 October 2006 - 05:56 AM

How do I check that?

#8 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 03 October 2006 - 05:57 AM

This is actually the whole error so the email addy is valid I think.

Warning: mail(): Bad parameters to mail() function, mail not sent. in /home/content/g/o/l/goldenhills/html/email_us.php on line 62

Thanks!
Email has been sent to:
admin@xxxxxxxx.com


I left out the website for confidentiality reasons.

#9 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 03 October 2006 - 04:31 PM

I still need help! I can't launch my website without fixing this error. Please help!

#10 mschrank

mschrank
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 03 October 2006 - 05:21 PM

Hmm, why are you putting newlines at the end of your string arguements? (\r\n)

Could that be it? I'd get rid of them and see.

#11 krizzone

krizzone
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 04 October 2006 - 01:39 AM

That's how the script is by default. It's for a website. Every page is pretty much php but I'm only having problems with the 'Contact' page.


Any other ideas. It says email is sent when I test it but I don't receive anything. Why and how would I go about fixing it? Do I need to mess with MySQL?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users