0

I'm Creating a weekly Updates to my clients, and I want to include the latest (News, Articles, Photos) in this mail. So I created "webmail.php" page that's been created Dynamically using MySql, contains all my updates I want to send to my clients, with heavy css and html contents. I'm using this PHP code in my script

ob_start();
include ('webmail.php');
$content = ob_get_clean();
$message = $content;
mail($email,$subject,$message,$headers); 

The problem is I'm facing (500 Internal Server Error). I'm sure that my webmail.php contains no errors and this problem happens because this page has been created Dynamically. Any Idea to solve this problem?. Thanks

1
  • 2
    if your php had no errors, then you wouldn't be getting a 500. Check your webserver's error log for more details. What you've posted is semantically correct PHP, and is absolutely useless for debugging, because that code snippet has NOTHING wrong with it. Whatever the bug is, it's inside webmail.php, which you haven't shown at all Commented Mar 6, 2014 at 1:23

1 Answer 1

2

I think you're missing a point there... If webmail.php is dynamically generated (which means it actually contains your information), then you can read its contents using :

$news = file_get_contents("webmail.php");

and just send $news as your email body. However, if webmail.php actually generates the content (which means it produces it when passed to the PHP interpretor), then maybe you should consider using a function in this file instead :

webmail.php

function latest_news(){
    // Gets news from database, put them into $news.
    return $news;
}

Then, on your first page (sending the email) :

include_once("webmail.php"); // Get the function.
mail("[email protected]", "Our latest news", latest_news());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.