<?php
include("include/head.php");
include("include/headder.php");
if(isset($_POST['submitfrm']))
{
if($_REQUEST['captchares'] != 1)
{
echo "<script> window.location='page-full-width.php?capterror'; </script>";
exit;
}
else
{
$username=$_REQUEST['username'];
$useremail=$_REQUEST['useremail'];
$mobile=$_REQUEST['mobile'];
$comment=$_REQUEST['comment'];
$contact=mysql_query("INSERT INTO `contactus` (`username`, `useremail`, `mobile`, `comment`) VALUES ('$username', '$useremail', '$mobile', '$comment')");
$conatctid=mysql_insert_id();
if($contact)
{
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = $smtphost;
$mail->Port = 25; // or 587
$mail->IsHTML(true);
$mail->Username = $smtpmail;
$mail->Password = $smtppassword;
$mail->SetFrom = $smtpmail;
$mail->Subject = "Enquiry";
$mail->Body = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='#006699' style='border:solid 10px #006699; width:550px;'>
<tr bgcolor='#006699' height='25'>
<td><img src='$sitelogo' border='0' width='200' height='60' /></td>
</tr>
<tr bgcolor='#FFFFFF'>
<td> </td>
</tr>
<tr bgcolor='#FFFFFF' height='30'>
<td valign='top' style='font-family:Arial; font-size:12px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'>This mail is sent from <b> $website_name </b> Regarding your enquiry</td></tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>Our support team will get you soon, Dear $username </td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>We will response to :$useremail</td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>Our notifications and offers sent as per your willingness to :$mobile</td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>Your enquiry :$comment</td>
</tr>
</table>";
$mail->AddAddress($useremail);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
//==================================Send mail to admin==========================================
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = $smtphost;
$mail->Port = 25; // or 587
$mail->IsHTML(true);
$mail->Username = $smtpmail;
$mail->Password = $smtppassword;
$mail->SetFrom = $useremail;
$mail->Subject = "Enquiry";
$mail->Body = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='#006699' style='border:solid 10px #006699; width:550px;'>
<tr bgcolor='#006699' height='25'>
<td><img src='$sitelogo' border='0' width='200' height='60' /></td>
</tr>
<tr bgcolor='#FFFFFF'><td> </td></tr>
<tr bgcolor='#FFFFFF' height='30'>
<td valign='top' style='font-family:Arial; font-size:12px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'>This mail is sent from <b> $website_name </b> Regarding your enquiry</td></tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>User Name: $username </td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>User Email: $useremail</td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>User Mobile: $mobile</td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>User enquiry :$comment</td>
</tr>
</table>";
$mail->AddAddress($website_admin);
//==============================================================================================
echo "<script> window.location='page-full-width.php?sent'; </script>";
exit;
}
}
}
}
邮件发送给用户但邮件未收到管理员..请帮帮我... 我想在发送询问时向用户发送邮件,并在用户询问产品时向管理员发送邮件。
答案 0 :(得分:1)
Following my comment,我会将其作为答案发布,因为它似乎是您问题的根源。
您忘记在$mail->Send();
之后写$mail->AddAddress($website_admin);
。
这就是邮件没有发送的原因。你还没有告诉PHP这样做。
添加此行(就像您为第一封电子邮件所做的那样),您就可以了。
答案 1 :(得分:-1)
您没有致电$mail->Send();
为您发送&#34;发送邮件给管理员&#34;部分代码。