Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6737973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:18:45+00:00 2026-05-26T11:18:45+00:00

Possible Duplicate: Problem when loading php file into variable (Load result of php code

  • 0

Possible Duplicate:
Problem when loading php file into variable (Load result of php code instead of the code as a string)

I am bit confused about following…

message alert function

public static function MsgAlert($email, $name, $subject, $message)
{
    $msg = include('mailer.php');

    $subject = 'New Message';

    if ($email != '' && validate_email($email))
    {
        $mailer = new PHPMailer();

        $mailer->SetFrom(ADMIN_EMAIL, SITE_NAME);
        $mailer->AddAddress($email);
        $mailer->Subject = $subject;
        $mailer->Body = Postman::nl2br($msg);
        $mailer->AltBody = $msg;
        $mailer->Send();
    }
}

I have put my newsletter design into mailer.php, and please check markup for that…

mailer.php

<div>
<h1><?php $subject; ?><span>27 September 2011 at 6:26 pm</span></h1>
<div>
<p>Hello <?php $name; ?>,</p>
<?php $message; ?>
</div> <!--message container -->
</div>

Am i using correct approach or should i do something more better as its not working. please suggest. thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:18:45+00:00Added an answer on May 26, 2026 at 11:18 am

    You cannot include to a variable, but what you can do is use php’s output buffering functions to achieve the desired outcome, e.g.:

    ob_start();
    include 'mailer.php';
    $msg = ob_get_clean();
    

    This will render the template and store the result in $msg.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What's wrong with Delphi's “with” I am have a problem debugging code
Possible Duplicate: problem with template inheritance This code doesn't compile in GCC: template <typename
Possible Duplicate: Solution to a recursive problem (code kata) give an algorithm to find
Possible Duplicate: C++ overload resolution I ran into a problem where after my class
Possible Duplicate: php warning mysql_fetch_assoc I have a weird problem about my script. It
Possible Duplicate: How to access a variable in a PHP class that is set
Possible Duplicate: Dynamically loading an external CSS file I'm trying to create a dynamic
Possible Duplicate: .htaccess Problem - ( Turn off SSL for every page except login.php
Possible Duplicate: Divide problem Why does c# show the output of this code as
Possible Duplicate: PHP Integer Problem 1.0000241703257e+14 how to convert it in PHP, it was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.