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 = '[email protected]';
      $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
https://forums.phpfreaks.com/topic/66103-sending-email/
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
https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330624
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
https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330626
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
https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330654
Share on other sites

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.