Adding an external mesage to php sendmail

This has to be a simple and stupid question but cant seem to figure it out. What I want to do is something like:

$message = include ('./myfile.php');

Obviously such does not work, but is there a way to accomplish this if that code worked.

Thanx

Here is full code (abbreviated):

        require_once ('./connect.php');
    $db = mysqli_connect($db_hostname,$db_username,$db_password,"paratb_members");
    $result = mysqli_query($db,"SELECT * FROM board where accesskey = 'CHHXN5Jdwu'");
    while ($row = mysqli_fetch_array($result)) {
    extract($row);
    $message = include './questions/resignation.php'; 

    $subject = "IAP Ballot";    
    $headers = "From: xxxx" . "\r\n";
    $headers .= "Reply-To: xxxx" . "\r\n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $fromEmail = "xxxx";
    $fifth = "-f" . $fromEmail;
    $to      = "$fname $lname <$email>";
    mail($to, $subject, $message, $headers, $fifth);    
    echo "Email sent to $lname: $email<br>";

1 answer

  • answered 2018-06-25 05:07 Shivrudra

    You can first read file & store data in variable which contain file's data then you can use that variable.

    fopen("myfile.php", "r");
        $lines = file("myfile.php");
        $message = '';
        foreach($lines as $value) {
            $message .= $value." ";
        }
        echo ($message);