how to send mysql fetch records php page via email
when i send a page via email it shows the php code. it does not fetch the details from mysql and then i'm fetching the mysql records based on the particular voucher id. how to send mysql fetch records page via email? look at this coding..
<?php
require_once('phpmailer/class.phpmailer.php');
include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('print.php[HERE HOW CAN I FETCH MYSQL RECORDS OF PARTICULAR VOUCHER ID]');
$body = preg_replace('/\/b]/','',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // Email username
$mail->Password = "mypassword"; // Email password
$mail->SetFrom('[email protected]', 'Subject Line');
$mail->AddReplyTo("[email protected]","Subject Line");
$mail->Subject = "Full Subject Line";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$email = $_POST['email'];
$mail->AddAddress($email);
if(!$mail->Send()) {
echo "<div align=center style=\"color:#FF0000; font-family: 'Times New Roman', Times, serif; font-size: 26px;\">Could not send email to : . $mail->ErrorInfo</div>";
} else {
echo "<script> alert('Mail successfully sent to $email') </script>";
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=mainpage.php">';
exit;
}
?>
i want to fetch mysql records here based on the particular voucher id. if user clicks the voucher id 10, it will show the full details of voucher id 10. and then i want to send that page via email. now i received an email. but i didn't get the mysql records of that particular id. how to do that?
Answer
Solution:
i posted another question here (send an email with mysql fetch records). i got help from that post. so, i posted the correct answer below.
Answer
Solution:
I hope this will help you