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
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("recipient#address.tld", "Our latest news", latest_news());
Related
I have a page where on form submit from previous page a div with something like invoice is created. I send that data to server and populate the invoice for print/generate PDF etc.
if (isset($_POST['kreiraj'])) {
$emailuser = $_POST["na_email"];
}
On same page I create with JS a PDF from canvas of that invoice and send it via Ajax for posting into PHP mail script witch is also on same page.
if (isset($_POST['fileDataURI'])) {
$pdfdoc = $_POST['fileDataURI'];
};
This all works but I have problems accessing PHP variables from each other.
I have read about function global and $_GLOBLAS[varables] but nothing seems to work for me. Can someone point out a way to do it?
TO be exact i need to access $emailuser from example code above in if (isset($_POST['fileDataURI'])) php mailing script.
I need to pass HTML to the following function
$response = good_mail_using_mandrill($to,$subject,$body,$from_name,$from_email,$MandrilluserAPIKey,$SubAccountID );
At the moment $body takes the entire HTML content from a MySQL field and sends the API call to Mandrill.
What I find is that certain HTML goes through but others dont. I am not sure what tags in the HTML cause this failure. Are there any restrictions on what content can be sent in the $body variable?
This is driving me nuts. Mandrill says that they are receiving "null" content.
Is there a way to read the API call at delivery?
I am trying to send mail using phpmailer, so my function which is returning body of mail,is like :
function get_include_contents(){
// some code
include "graph.php"
//some code<br/>
}
"graph.php" file is actally generating a table and graph (i am using highchart.js) ,
when I run my file to send mail , I am getting table only (which is generated in php).
I am not getting graph(which is geneated in by javascript).
How should I display graph in mail ?
Imho you're best shot is to make a pdf out of the graph.php page and use that pdf as an attachment in your email. This process has been discussed here Print a webpage to pdf document using php
I have data in string format in a single variable in a php file on a wordpress site.
I want to fetch that variable's value through a php file on different server.
I want a way which will send that variable to my receiving php file that I have created on different server and print that values here.
In short, e.g. let there is data in mydomain1.com/send.php
which need to be stored or displayed in mydomain2.com/receive.php
But, without using form.There is no html form in sending file and also I don't want it since no redirection should be done.Just on a function execution in sending file data need to be transferred and displayed only on receiving end.
(I tried to find out solution for this using cURL.But, everywhere I found code to send data but what about receiving data, how can I capture that sent data and display at receiving end.)
If there is another solution except cURL or form submission I would appreciate.
Please help soon.
there are a lot of ways to do this, one way would be a SOAP client/server solution..:
you have basically 2 php files, one file on server1 is let say the client.php and on the other server there is the file named server.php which will receive all the data sent from client.php on server 1... here is a simple source, you need to change the URLs in the script to your server/client URLs so it works..:
client.php
<?php
//This is the SOAP Client which will call a method on Server 2 with passing some data:
//uri is the location where client.php is located, and "location" is the exact location to the client, including the name "client.php"
$client=new SoapClient(NULL,array("uri"=>"http://localhost/test","location"=>"http://localhost/test/test.php"));
$message=$client->hello("Hello World");
echo($message);
?>
server.php
<?php
//This is the SOAP Server
class server2{
public function hello($data){
return "I received following data: " . $data;
}
}
//the URI here is the location where the server.php is located.
$settings = array("uri"=>"http://localhost/test/");
$s=new SoapServer(null,$settings);
$s->setClass("server2");
$s->handle();
?>
Here's a tutorial: http://davidwalsh.name/execute-http-post-php-curl
Basically you can send the urlencoded values using CURLOPT_POSTFIELDS
I currently have two php files (header and footer) on my server that is used as a template and is retrieved on another server that wraps the template files around their software.
Is it possible to display different content based on their url in my template files in php? If so, how?
I don't know if this matters, but the other server uses coldfusion and not php.
The php file could check a parameter in the url, like template.php?url=stackoverflow , so in the php file you could check
if ($_GET['url']=='stackoverflow'){
echo "Stack Overflow template";
}else if ($_GET['url']=='lol'){
echo "Another template";
}else{
echo "error";
}
Edit:
Now the server getting the content, just needs to add that parameter to the url and it gets the template that it wants. You could set a default template in case no parameter is specified.
Would it be possible for their url to contain a get variable like www.theirwebsite.com/?chrome=red? then your file could read that and parse out different themes based on what the variable's value is.
NOt quite sure if I'm understanding you, but you can certainly display different content based on a url.
$remote_content = file_get_contents($someurl);
switch $someurl
case 'www.google.com':
display_google_content();
break;
case 'www.microsoft.com':
throw(BSOD);
break;
default:
display_standard_content();
}
There are two obvious possibilities for how the remote server is attaching your code that spring to mind. The first is using JavaScript to instruct the client to go out and get your content, then write it to the appropriate locations. This should be rather obvious when looking at the HTML source code generated by their application.
The more likely scenario, in my opinion, is that they use CFHTTP to retrieve the content and inject it directly. CFHTTP mimics a broser call -- it's a standard HTTP 1.1 request. It's not going to contain a reference to the url requested on their server. Unless you can convince them to add identifying information to the request, all you'll be able to tell on your server is that the request came from CF (by examining the remote agent).