Jump to content

[SOLVED] mail() is not working, showing some error, what to do now ?


ankur0101

Recommended Posts

Hi, I am newbie

I am making a script which sends email.

It contains 2 pages

 

Code of 1st page i.e. first_email.php is here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<h2 align="center"> |<a href="control_panel.php">Control Panel</a> | <a href="first_email.php">1st E-mail</a> | <a href="second_email.php">2nd E-mail</a> |  <a href="third_email.php">3rd E-mail</a> | <a href="settings.php">Settings</a> |</h2>
<p align="center"> </p>
<form id="form1" name="form1" method="post" action="send_mail.php">
  <table width="859" border="0">
    <tr>
      <td width="236"> </td>
      <td width="96">To :</td>
      <td colspan="2"><label>
        <input name="email_text_box" type="text" id="email_text_box" size="70" maxlength="100" />
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td>Subject :</td>
      <td colspan="2"><label>
        <input name="subject_text_box" type="text" id="subject_text_box" value="Testing Testing ..." size="70" maxlength="100" />
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td>From :</td>
      <td colspan="2"><label>
        <input name="from_text_box" type="text" id="textfield" size="70" maxlength="100" />
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td>Message :</td>
      <td colspan="2"><label>
        <textarea name="message_text_box" id="textarea" cols="67" rows="5">Message</textarea>
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td>Attachments :</td>
      <td colspan="2"><p> </p>
      <p> </p></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td width="81"><label>
        <input type="submit" name="submit" id="submit" value="Send" />
      </label></td>
      <td width="428"><label>
        <input type="reset" name="Reset" id="Reset" value="Reset" />
      </label></td>
    </tr>
  </table>
</form>
<p align="center"> </p>
</body>
</html>

 

Code of second page i.e. send_mail.php is here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<h2 align="center"> |<a href="control_panel.php">Control Panel</a> | <a href="first_email.php">1st E-mail</a> | <a href="second_email.php">2nd E-mail</a> |  <a href="third_email.php">3rd E-mail</a> | <a href="settings.php">Settings</a> |</h2>
<p align="center"> </p>
<p align="center" class="style1">
<?php 

$to = $_POST["email_text_box"];
$from = $_POST["from_text_box"];
$subject = $_POST["subject_text_box"];
$message = $_POST["message_text_box"];
$headers = "From: " . $from . "\r\n";
$mailsent = $mail($to, $subject, $message, $headers);
if ($mailsent) {
echo "Congrats !!! The following message has been sent: <br></br>";
echo "<b>To:</b> $to <br>";
echo "<b>From:</b> $from <br>";
echo "<b>Subject:</b> $subject <br>";
echo "<b>Message:</b><br>";
echo $message;
} else {
echo "There was an ERROR ... ";
}
?></p>
</body>
</html>

 

But after executing and filling data in first_email.php, it shows error

 

Fatal error: Function name must be a string in D:\xampp\htdocs\mailingscript\send_mail.php on line 19

 

What to do ?

I think everything is perfect. I am confused.

How can I attach file ? I read many articles on internet, but all are bit confusing. How can I incorporate them in my code ?

 

http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.