- <?php
-
$to = "someone2@example.com";
-
$subject = "Test mail";
-
$message = include("PROGRAMtoEXECUTE.html");
-
$from = "someone1@example.com";
-
$headers = "From: $from";
-
mail($to,$subject,$message,$headers);
-
echo "Mail Sent.";
-
?>
[Please use CODE tags when posting source code. Thanks! --pbmods]
This email contains a message which changes every time it is sent.
This changing message could be the time, some random numbers, etc..
Is there any way to have it run the program and then send the output?
2 1628
Yes, this is possible, however you don't want to use the include() function. Try using file_get_contents()
Your code would look like this: - <?php
-
$to = "someone2@example.com";
-
$subject = "Test mail";
-
$message = file_get_contents("PROGRAMtoEXECUTE.html");
-
$from = "someone1@example.com";
-
$headers = "From: $from";
-
mail($to,$subject,$message,$headers);
-
echo "Mail Sent.";
-
?>
I'm almost positive you can use this to get a file at a specific URL as well so if your file is a PHP file that you want to execute you can do a file_get_contents("http://www.mysite.com/php.php"); If that doesn't work, check out cURL on php.net and google. That should give you everything you'd need to know. - <?php
-
$to = "someone2@example.com";
-
$subject = "Test mail";
-
$message = include("PROGRAMtoEXECUTE.html");
-
$from = "someone1@example.com";
-
$headers = "From: $from";
-
mail($to,$subject,$message,$headers);
-
echo "Mail Sent.";
-
?>
[Please use CODE tags when posting source code. Thanks! --pbmods]
This email contains a message which changes every time it is sent.
This changing message could be the time, some random numbers, etc..
Is there any way to have it run the program and then send the output?
Thank you Bergy!
I tried using file_get_contents(), with the txt, html and php extensions,
but this only gets the text of the program source codes, and does
not execute or run the program first, and then output the results.
For example, Save these 3 lines as "date.php".
<html><head></head><body>
<?php print date("Y-m-d"); ?>
</body></html>
And put "date.php" into the $message.
If you then send the email, you will receive the above 3 lines of code
and not the output of running those 3 lines of code.
I want to email only the program output and not the source code.
Perhaps, I should be looking for a completely different method?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: wEEdpEckEr |
last post by:
Hi,
here's the deal:
I have a config.php file in which I have set a few var's, to use in the
whole site. E.g.:
$db_host = "localhost";
Then I also have a class, which is supposed to...
|
by: Kupo |
last post by:
Hi, I'm currently writing website using php. My problem is, when I do:
include("../../library/file.php"); // this is from e.g
/level1/level2/something.php
it works. However, when I use:
...
|
by: Tom |
last post by:
I'm tying myself in knots trying to figure out variable scope with
constants and include files. This is what I'm doing:
A page (index.php) on my website includes a general purpose include
file...
|
by: r6uji7 |
last post by:
hello,
i am new to PHP programming and wondered if u could help.
lets say i have the following files:
1. error.php: that is routed to for all errors. this page should
display proper and...
|
by: Wilk Teverbaugh |
last post by:
I've got an include file inside each page throughout my site. Inside this
include file I'm running server.execute to include other pages based on a
condition (userID).
The problem has two parts-...
|
by: Kouisawang |
last post by:
Hello all,
I have a question when I found the following code;
--------------------------------------------------------------------------------------
#ifndef FOO_H
#define FOO_H
//some more...
|
by: McKirahan |
last post by:
I am looking for feedback on an approach to using PHP.
Below is a stripped down version of a Home page: "index.php".
The content of the site is displayed in the middle of the page and
is...
|
by: cybervigilante |
last post by:
I can't seem to change the include path on my local winmachine no
matter what I do. It comes up as
includ_path .;C:\php5\pear in phpinfo() but there is no such file. I
installed the WAMP package...
|
by: travispennington |
last post by:
To anyone that can assist me: I deeply appreciate your help!!
I am developing an application with an outside vendor. The vendor has
a very odd requirement. They need custom X-Headers added to...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |