Jump to content

Sending email


forumnz

Recommended Posts

Hi, I have a script I made and I can't get it to work. It is meant to send an email to me and include email.php in the body.

I think the error is where it does try to include it.

 

Please help thanks. Sam.

 

<body>
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];
?>
   <form name="form1" method="post"
         action="<?php echo $me;?>">
      <table border="0" cellspacing="0" cellpadding="2">
         <tr>
            <td>Name:</td>
            <td><input type="text" name="Name"></td>
         </tr>
         <tr>
            <td>Subject</td>
            <td><input type="text" name="Subject"></td>
         </tr>
      
         <tr>
            <td> </td>
            <td><input type="submit" name="Submit"
               value="Send"></td>
         </tr>
      </table>
   </form>
<?php
   } else {
      error_reporting(0);
      $recipient = 'abc@abc.abc';
      $subject = stripslashes($_POST['Subject']);
      $from = stripslashes($_POST['Name']);
      $msg = ($GET['email.php']);
      if (mail($recipient, $subject, $msg))
         echo nl2br("<b>Message Sent:</b>
         To: $recipient
         Subject: $subject
         Message:
         $msg");
      else
         echo "Message failed to send";
}
?>
</body>

Link to comment
Share on other sites

You are missing the brackets for the last if and else statements:

 

      if (mail($recipient, $subject, $msg))
         echo nl2br("<b>Message Sent:</b>
         To: $recipient
         Subject: $subject
         Message:
         $msg");
      else
         echo "Message failed to send";

 

      if (mail($recipient, $subject, $msg)){
         
         echo nl2br("<b>Message Sent:</b>
         To: $recipient
         Subject: $subject
         Message:
         $msg");
         }
      else{
         echo "Message failed to send";
         }

     

Link to comment
Share on other sites

Hi..

          Check the $msg var at the time of sending mail.. What r u getting in it?

          and you have written $GET['email.php'] .. is it ok..? What is it mean..?

          if its ok then   

          make error reporting on and check what error r u getting..         

 

Regards,

Vijay

 

Link to comment
Share on other sites

Thanks that works, however the HTML code is shown - Basically this is the early stages. This script will send heaps of emails with unique invoices. The email.php file will pull info. for each invoice from a db and display it in the emails.

 

Is there an easier way?

Link to comment
Share on other sites

Hi..

          so you mean to say for every invoice there will be some content would be dynamic..

          if such that then use following         

         

<?php 
          $msg= implode('', file('http://myhost/myfilepath/file.php')); 
          /** OR **/
          $msg = '<html>yr content. hi..'.$name.'</html>';
          ?>

 

Regards,

Vijay

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.