Jump to content

Sending php results to the end user through email


tamanna

Recommended Posts

I want to do something like this,

 

I had a html query submission form linked to php.

 

I want to send the output generated after php execution to the user through mail id provided in the form, in a manner such that when user click submit button, he well be redirected to thank you page and php keeps on running in the background and as soon as the output is generated, it will be send to the end user through email. As my query takes time to execute, so I don't want the end user to keep waiting till the program gets finish.

 

 

Here is my code:

 

<?php
$seq = $_POST['seq'];
    if (isset($_POST['seq']))
    {
$b = fopen("sequence.txt", "w");
fwrite($b, $seq);
fclose($b);
system("perl /opt/lampp/htdocs/matepred/blast/bin/scriptforblastcompleterun.pl sequence.txt nr > out");
system("perl /opt/lampp/htdocs/matepred/blast/bin/format.pl > output");
system("perl /opt/lampp/htdocs/matepred/blast/bin/testing.pl output");
  echo "<div align='center'><font color='blue'><b>RESULT</font></div>";
$i=1;
$files = array();
foreach (glob("file_*.out")as $file)
{
 $files[] = $file;
$b = fopen("/opt/lampp/htdocs/matepred/blast/bin/$file", "r");
$s=fgets($b);
fclose($b);
echo "<table border=10. align=center><tr bgcolor=lightgreen><th>SerialNo</th><th>Value</th><th>Decision</th><th></tr>";
echo '<td>'. $i++
. '</td>';
   
echo "<td>$s</td>";
if($s>=0)
{
echo "<td>Yes</td>";
}
else
{

echo"<td>No</td>";
}
echo "</table>";

}
}

?>

 

html table part marked in red here is the output which I want to send back to the user.

 

Can anybody help me in linking my php output to the mail.

Thanks in advance.

 

 

It would be interesting to know a good solution to this. My first thoughts would be to have different threads handling this, one handling your presentation logic and another handling the e-mail side of things - I may be incorrect here, so will be best to wait for some of the more experienced developers to have their input.

I had saved the results in a text file and now  trying to send these to the user via provided mail using localhost on ubuntu system.

 

Code :

 

$to=$_POST['email'];
$subject='Your  results';
$body=$data;    (//here $data stores the output file in text format)
$from="http://localhost/matepred/blast/bin/new.php";
mail( $from, $to, $subject, $body);

 

 

But it isn't sending any mail. Can anyone help me to know the problem with the code. Or is this a  problem with localhost?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.