Avatar of nzrubin
nzrubinFlag for New Zealand

asked on 

include file in phpMailer email body

Hello guys
im using phpmailer to send emails.
i m trying to include case_study.php file to send, can i do this? and how do i do this?
thanks
$mail = new PHPMailer();
		$mail->Subject = $_POST['subject'];
		$mail->From = $_POST['from'];
		$mail->FromName = $_POST['fromName'];
				
		$mail->Body = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
	<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />	
</head>
".include("pages_to_include/case_study.php")."
</body>
</html>";
		$mail->AddAddress($_POST['to'],$_POST['toName']);
		$mail->AddBCC($_POST['bcc']);
		$mail->IsHTML(true);
		$mail->Send();

Open in new window

PHP

Avatar of undefined
Last Comment
nzrubin
Avatar of Karai_17
Karai_17
Flag of Canada image

I think this should work:
<?php
$header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
        <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />       
</head><body>";
 
$caseStudy = include("pages_to_include/case_study.php");
 
$footer = "</body>
</html>";
 
$body = $header . $caseStudy . $footer;
?>

Open in new window

Avatar of nzrubin
nzrubin
Flag of New Zealand image

ASKER


$caseStudy = include("pages_to_include/case_study.php");
            
$mail->Body = $caseStudy;

doesnt work
ASKER CERTIFIED SOLUTION
Avatar of Karai_17
Karai_17
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of nzrubin
nzrubin
Flag of New Zealand image

ASKER

thanks
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo