ngrmm Posted January 16, 2020 Share Posted January 16, 2020 (edited) I have a page which sends out an email based on queries in the url <?php // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $adminEmail = "events@test.com"; $fromEmail = "noreply@test.com"; $fromName = "test"; $emailSubject = "Test Email"; // HTML BODY $emailBody = ""; // HOW TO ??? … // send mail $m = new WireMail(); $m->to($adminEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); ?> The email body is a bit complex: standard html/css tables and some php (pw variables). I put my emailbody (html) in a seperate file emailbody.inc but don't know how to include it? Edited January 16, 2020 by ngrmm solved Link to comment Share on other sites More sharing options...
Kiwi Chris Posted January 16, 2020 Share Posted January 16, 2020 You could use PHP output buffering to read your file into a variable. Something like: ob_start(); include('./emailbody.inc'); $emailBody = ob_get_clean(); 2 Link to comment Share on other sites More sharing options...
ngrmm Posted January 16, 2020 Author Share Posted January 16, 2020 @Kiwi Chris thx! Link to comment Share on other sites More sharing options...
Robin S Posted January 16, 2020 Share Posted January 16, 2020 An alternative is to use $files->render($filename). See the documentation about where the file is allowed to be. $emailBody = $files->render('/path/to/emailbody.inc'); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now