Php 发送包含mysql获取记录的电子邮件
现在,我想生成一个客户凭证,然后将其发送给特定的个人电子邮件id。我已经使用phpmailer完成了基本的邮件功能。现在,我收到一封电子邮件,但我没有得到mysql数据。我试过了。但它不起作用。例如,如果我单击凭证id 7,它将显示凭证id 7的全部详细信息。我想将特定的(凭证id 7)数据发送到电子邮件Php 发送包含mysql获取记录的电子邮件,php,mysql,email,phpmailer,Php,Mysql,Email,Phpmailer,现在,我想生成一个客户凭证,然后将其发送给特定的个人电子邮件id。我已经使用phpmailer完成了基本的邮件功能。现在,我收到一封电子邮件,但我没有得到mysql数据。我试过了。但它不起作用。例如,如果我单击凭证id 7,它将显示凭证id 7的全部详细信息。我想将特定的(凭证id 7)数据发送到电子邮件 $body = file_get_contents('print.php'); 这里我如何将mysql_fetch记录插入电子邮件正文页。。。?我希望有人能告诉我这个问题的答案 这是我的pr
$body = file_get_contents('print.php');
这里我如何将mysql_fetch记录插入电子邮件正文页。。。?我希望有人能告诉我这个问题的答案
这是我的print.php页面编码:
if(isset($_GET['id']))
{
$id = mysql_real_escape_string($_GET['id']);
$query = mysql_query ( "SELECT * FROM voucher WHERE voucherno = $id" );
$row = mysql_fetch_object($query);
echo mysql_error();
<tr>
<td width=193 height=40 class=rightstyle>Voucher Number : </td>
<td width=229 class=leftstyle> $row->voucherno </td>
<td width=234 class=rightstyle>Reference Number : </td>
<td width=234 class=leftstyle> $row->reference </td>
</tr>
}
if(isset($\u GET['id']))
{
$id=mysql\u real\u escape\u字符串($\u GET['id']);
$query=mysql\u query(“从凭证中选择*,其中voucheno=$id”);
$row=mysql\u fetch\u对象($query);
echo mysql_error();
凭证编号:
$row->voucherno
参考编号:
$row->reference
}
我仍然从mysql数据库中获取大量数据。所以我想在这个页面(包括mysql数据)发送一封电子邮件。试试这个。。。。。。
$check=mysql\u查询(“从tbl\u用户中选择*,其中uid='$\u会话[uid]'”;
$percent=mysql\u fetch\u assoc($check);
$email=$percent['email'];
$to=“$email”;
$subject=“subject”;
$message=”
要求
你好
";
//发送HTML电子邮件时始终设置内容类型
$headers=“MIME版本:1.0”。“\r\n”;
$headers.=“内容类型:text/html;字符集=iso-8859-1”。“\r\n”;
//更多标题
$headers.='发件人:您的电子邮件id'。“\r\n”;
邮件($to、$subject、$message、$headers);
试试这个。。。。。。
$check=mysql\u查询(“从tbl\u用户中选择*,其中uid='$\u会话[uid]'”;
$percent=mysql\u fetch\u assoc($check);
$email=$percent['email'];
$to=“$email”;
$subject=“subject”;
$message=”
要求
你好
";
//发送HTML电子邮件时始终设置内容类型
$headers=“MIME版本:1.0”。“\r\n”;
$headers.=“内容类型:text/html;字符集=iso-8859-1”。“\r\n”;
//更多标题
$headers.='发件人:您的电子邮件id'。“\r\n”;
邮件($to、$subject、$message、$headers);
但我没有收到任何电子邮件..?您是否使用了phpmailer库?是否更新了主机名、用户名、密码和addAddress电子邮件id?您是在本地主机上还是在服务器上使用此代码?您应该在服务器上尝试此代码。并检查您的邮件是否不会发送垃圾邮件。我更新了我的问题。再看看我的问题。我更改了与您的编码相关的编码..但我没有收到任何电子邮件..?您是否使用了phpmailer库?您是否更新了主机名、用户名、密码和addAddress电子邮件id?您是在本地主机上还是在服务器上使用此代码?您应该在服务器上尝试此代码。并检查您的邮件是否不会发送垃圾邮件。我更新了我的问题。再看看我的问题。我更改了与您的编码相关的编码。。
Try this......
$check=mysql_query("SELECT * FROM tbl_user WHERE uid='$_SESSION[uid]'");
$percent=mysql_fetch_assoc($check);
$email=$percent['email'];
$to = "$email";
$subject = "Subject";
$message = "
<html>
<head>
<title>Request</title>
</head>
<body>
<font size='20px'>Hello </font>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From:Your email id' . "\r\n";
mail($to,$subject,$message,$headers);
<?php
ob_start();
//smtp detail start
require_once ('class.phpmailer.php' );
$mail=new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
//SMTP detail from here
//$mail->SMTPSecure = "ssl";
$mail->Host = "yourhostname"; // sets GMAIL as the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "you@yourdomain.com";
$mail->Password = "yourpassword";
//$mail->SMTPDebug=1;
//SMTP deatil end
//smtp mail end
if(isset($_GET['id']))
{
$id = mysql_real_escape_string($_GET['id']);
$query = mysql_query ( "SELECT * FROM voucher WHERE voucherno = $id" );
while($row = mysql_fetch_object($query))
{
$strMessage = "<tr>
<td width=193 height=40 class=rightstyle>Voucher Number : </td>
<td width=229 class=leftstyle> $row->voucherno </td>
<td width=234 class=rightstyle>Reference Number : </td>
<td width=234 class=leftstyle> $row->reference </td>
</tr>";
}
// $flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No show error //
$mail->FromName = "your name";
$mail->From = "your mail id";
$mail->ContentType ="text/html";
$mail->AddAddress('test@testing.com');//mail will be send on this email
$mail->Subject='customer voucher';
$mail->Body = $strMessage;
if($mail->Send())
{
echo "mail send.";
}
else
{
echo "Cannot send mail.";
}
}
ob_flush();
?>