forumnz Posted August 22, 2007 Share Posted August 22, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/ Share on other sites More sharing options...
jcanker Posted August 22, 2007 Share Posted August 22, 2007 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330624 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 wat s d error ur getting? Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330625 Share on other sites More sharing options...
vijayfreaks Posted August 22, 2007 Share Posted August 22, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330626 Share on other sites More sharing options...
forumnz Posted August 22, 2007 Author Share Posted August 22, 2007 It all wors fine except for the message body. With the script I posted, I get email.php in the body of the email. What needs to replace that part? Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330628 Share on other sites More sharing options...
vijayfreaks Posted August 22, 2007 Share Posted August 22, 2007 Hi.. may i know.. Whats this..? $GET['email.php'] is it ok..? is there any file like email.php that u want to include... -Vijay Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330629 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 $msg = ($GET['email.php']); s tat valid..shudnt it b $msg = ($_GET['email.php']); ? Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330630 Share on other sites More sharing options...
forumnz Posted August 22, 2007 Author Share Posted August 22, 2007 Hi.. may i know.. Whats this..? $GET['email.php'] is it ok..? is there any file like email.php that u want to include... -Vijay Yes there is a file named email.php that I want to include. Sam. Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330633 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 to include the file, u can use include() / require() function. Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330636 Share on other sites More sharing options...
vijayfreaks Posted August 22, 2007 Share Posted August 22, 2007 Hi.. then you have to go for file reading and get its content in some var and that you have to pass here... may I have that file's code? Regards, -Vijay Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330637 Share on other sites More sharing options...
forumnz Posted August 22, 2007 Author Share Posted August 22, 2007 It is just html tags with the word TEST in the body. What I want it to do is send an email to me with the email.php content in the body DOes that make sense? Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330640 Share on other sites More sharing options...
pranav_kavi Posted August 22, 2007 Share Posted August 22, 2007 u can ve the entire file content widin the variable itself.y do u need a file for tat? incase the file is mandatory,read the contents of the file and append it to $msg. Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330642 Share on other sites More sharing options...
vijayfreaks Posted August 22, 2007 Share Posted August 22, 2007 Hi.. do the following if its only html. either assign all content to $msg var. like: $msg= '<html>yr content</html>' or you can do $msg= implode('', file('http://urhost/urfilepath/file.php')); Regards, Vijay Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330643 Share on other sites More sharing options...
forumnz Posted August 22, 2007 Author Share Posted August 22, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330647 Share on other sites More sharing options...
vijayfreaks Posted August 22, 2007 Share Posted August 22, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/66103-sending-email/#findComment-330654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.