RON_ron Posted December 14, 2011 Share Posted December 14, 2011 in my php - html email how can I add require() within the html body? <?php //other php functions "<HTML> email body section A ///////how do I add this php here? require( dirname( __FILE__ ) . '/../../folder/file.php' ); email body section B </HTML>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253142--/ Share on other sites More sharing options...
kney Posted December 14, 2011 Share Posted December 14, 2011 <?php //other php functions ?> <HTML> email body section A <?php require( dirname( __FILE__ ) . '/../../folder/file.php' ); ?> email body section B </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297753 Share on other sites More sharing options...
RON_ron Posted December 14, 2011 Author Share Posted December 14, 2011 Doesn't work... <?php //other php functions ?> $message = "<HTML> email body section A <?php require( dirname( __FILE__ ) . '/../../folder/file.php' ); ?> email body section B </HTML>" Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297769 Share on other sites More sharing options...
euel Posted December 14, 2011 Share Posted December 14, 2011 or try simply <?php //other php functions ?> <HTML> email body section A <?php require("filelocation.php"); ?> // make sure you got the exact location of your php file. email body section B </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297777 Share on other sites More sharing options...
RON_ron Posted December 14, 2011 Author Share Posted December 14, 2011 Keeping $message = " before the <HTML> is important to me. Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297788 Share on other sites More sharing options...
kney Posted December 14, 2011 Share Posted December 14, 2011 Post your total code then Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297789 Share on other sites More sharing options...
RON_ron Posted December 14, 2011 Author Share Posted December 14, 2011 it goes like this.... $to = $emailer; $sender = "Daisy Toys<newsletter@daisytoys.com>"; $subject = "Daisy Toys Newsletter for - $company"; $message = "<HTML> <head> ///////////other html Stuff <?php require( dirname( __FILE__ ) . '/../../folder/file.html' ); </BODY> </HTML>"; mail($emailer, $subject, "", $headers); Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297791 Share on other sites More sharing options...
kney Posted December 14, 2011 Share Posted December 14, 2011 Try <?php $to = $emailer; $sender = "Daisy Toys<newsletter@daisytoys.com>"; $subject = "Daisy Toys Newsletter for - $company"; $message = "<HTML><head>///////////other html Stuff " . require("filelocation.php") . "</BODY></HTML>"; mail($emailer, $subject, "", $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297795 Share on other sites More sharing options...
RON_ron Posted December 14, 2011 Author Share Posted December 14, 2011 Doesn't work? Is it possible to add a HTML there? Actually I want to embed an external HTML file within my newsletter HTML in php. .require( dirname( __FILE__ ) . '/../../folder/file.html' ). // path is correct Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297797 Share on other sites More sharing options...
RON_ron Posted December 14, 2011 Author Share Posted December 14, 2011 Could someone tell why isn't this working? <?php //other php functions ?> $message = "<HTML> email body section A <?php require( dirname( __FILE__ ) . '/../../folder/file.php' ); ?>//this is my problem - it's SHOWING BLANK here (the path is correct) email body section B </HTML>" Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297856 Share on other sites More sharing options...
floridaflatlander Posted December 14, 2011 Share Posted December 14, 2011 Are doing this on a php file? Are your paths correct? Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297858 Share on other sites More sharing options...
RON_ron Posted December 14, 2011 Author Share Posted December 14, 2011 yes, it's a php file and the path is correct. Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297859 Share on other sites More sharing options...
Pikachu2000 Posted December 14, 2011 Share Posted December 14, 2011 Do you have error reporting set up to show all errors? If not, you should. Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297862 Share on other sites More sharing options...
kicken Posted December 14, 2011 Share Posted December 14, 2011 Perhaps this is what you want? <?php ob_start(); require(dirname( __FILE__ ) . '/../../folder/file.php'); $output = ob_get_clean(); $message = "<HTML> email body section A ".$output." email body section B </HTML>" Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297920 Share on other sites More sharing options...
gizmola Posted December 15, 2011 Share Posted December 15, 2011 Require pulls php code or html into the php script. It does not read it as a string into a variable. Use file_get_contents $body = file_get_contents('path/to/file/filename'); $message = " email body section A $body email body section B "; Quote Link to comment https://forums.phpfreaks.com/topic/253142--/#findComment-1297991 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.