我发送动态创建电子邮件正文中的html表但在电子邮件中我收到的是html代码,而不是显示表格。请帮我。 这是我的代码。 我的服务器只支持此代码发送电子邮件 $ email_message =“name:”。cleanantring($ name)。“\ n”; 所以请帮我使用这段代码。
<?php
require ('class.phpmailer.php');
$name = @$_REQUEST['name'];
//$email = @$_REQUEST['email'];
$contact = @$_REQUEST['contact'];
$day = @$_REQUEST['day'];
$month = @$_REQUEST['month'];
$year = @$_REQUEST['year'];
$date_event = @$_REQUEST['date_event'];
$check = @$_REQUEST['check'];
$check_score = @$_REQUEST['check_score'];
$check_service = @$_REQUEST['check_service'];
$check_product = @$_REQUEST['check_product'];
$check_scheme = @$_REQUEST['check_scheme'];
$check_value = @$_REQUEST['check_value'];
$check_price = @$_REQUEST['check_price'];
$arr = array($year,$month,$day);
$doe_event = join("-",$arr);
$action=@$_REQUEST['action'];
$today=getdate();
$gday="$today[mday]";
$gmonth="$today[mon]";
$gyear="$today[year]";
$ghour="$today[hours]";
$gminutes="$today[minutes]";
$gsecond="$today[seconds]";
$create_date="$gyear-$gmonth-$gday $ghour:$gminutes:$gsecond";
if($action=='add') {
$email_to = "your email";
$email_subject = "Message From Website";
$error_message = "";
$email_exp = "^[a-z .'-]+$";
$email_message = "<strong>Contact form</strong><br>";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
//All data In table mail
$headers = "From: $ContactPerson<info@*******.co.in> \n";
$headers .= "Reply-To: $to \r\n";
$headers .= "X-Mailer: PHP/". phpversion();
$headers .= "X-Priority: 3 \n";
$headers .= "MIME-version: 1.0\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$email_message='<table cellspacing="0" cellpadding="0" border="1" align="center">
<tr>
<td bgcolor="#99CC00">Name ';
$email_message = "Quick enquiry detail.";
$email_message = " ".clean_string($name)."\n";'</td>
</tr>
</table>';
//$email_message .= clean_string($email);
//$email_message = "Quick enquiry detail.";
$email_message .= "name: ".clean_string($name)."\n";
$email_message .= "contact: ".clean_string($contact)."\n";
$email_message .= "doe: ".clean_string($doe_event)."\n";
if(isset($_REQUEST['check']) && count($_REQUEST['check']))
{
$recipient_email_addresses = array
(
);
foreach($_REQUEST['check'] as $value){
$email_message .= "services: ".clean_string($value)."\n";
};
}
// create email headers
$email_from="info@*******.co.in";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$_REQUEST['email']."\r\n" .
'X-Mailer: PHP/' . phpversion();
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->FromName = $_REQUEST['name'];
$mail->Host = 'mail.*******.co.in';
$mail->SMTPAuth = true;
$mail->Username = 'info@********.co.in';
$mail->Password = '********';
$mail->AddAddress("your email", "ADMIN");
$mail->Subject = "Contact Enquiry From www.********.co.in";
$mail->Body = $email_message;
if($mail->Send())
{
echo "<script>alert('Thank you for quick submit.') </script>";
echo "<script>location.replace('index.php?action=msgsent');</script>";
die;
}
else
{
echo "<script>alert('There was an error sending the message, Please try again.')</script>";
echo "<script>location.replace('index.php?action=msgerr');</script>";
die;
}
}
&GT;
答案 0 :(得分:3)
答案 1 :(得分:-1)
请参考w3schools.com。 在这里你可以通过例子找到合适的想法。 试试吧