<?php
include_once('admin/dbcon.php');
if(isset($_POST["submit"])=="Apply Now")
{
//$resume='';
//$photos='';
$fullname = strip_tags($_POST["fullname"]);
$address = strip_tags($_POST["address"]);
$state = strip_tags($_POST["state"]);
$city = strip_tags($_POST["city"]);
$mobile = strip_tags($_POST["mobile"]);
$email = strip_tags($_POST["email"]);
$username="xxxxxxx";
$apply_for = strip_tags($_POST["apply_for"]);
/*Resume file uploaded*/
$allowedExts = array("pdf", "doc", "docx");
$extension = end(explode(".", $_FILES["up_resume"]["name"]));
if ($_FILES["up_resume"]["type"] == "application/pdf" ||
$_FILES["up_resume"]["type"] == "application/msword" ||
$_FILES["up_resume"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
{
$type =substr($_FILES["up_resume"]["name"],strrpos($_FILES["up_resume"]["name"], '.') + 1);
$resume = "Resume_".time().".".$type;
move_uploaded_file($_FILES["up_resume"]["tmp_name"], "admin/upload/".$resume);
}
else
{
header("Location:apply-now.php?rm=Invalid file, Please upload your updated resume!!");
}
/*Photo uploaded here*/
$allowedExts1 = array("gif", "jpeg", "jpg", "png");
$extension1 = end(explode(".", $_FILES["profiel_photos"]["name"]));
if ($_FILES["profiel_photos"]["type"] == "image/gif" || $_FILES["profiel_photos"]["type"] == "image/jpeg" ||
$_FILES["profiel_photos"]["type"] == "image/pjpeg" || $_FILES["profiel_photos"]["type"] == "image/png" || $_FILES["profiel_photos"]["type"] == "image/jpg" )
{
$type1 =substr($_FILES["profiel_photos"]["name"],strrpos($_FILES["profiel_photos"]["name"], '.') + 1);
$photos = "prf_img_".time().".".$type1;
move_uploaded_file($_FILES["profiel_photos"]["tmp_name"], "admin/upload/".$photos);
}
else
{
header("Location:apply-now.php?pic=Invalid file,Please upload your updated photos!!");
}
$status = "INSERT INTO `caretel`.`tb_career` (`FullName`, `Address`, `State`, `City`, `ContactNo`, `Email`, `Resume`, `ProfileImg`, `ApplyFor`) VALUES ('$fullname', '$address', '$state', '$city', '$mobile', '$email', '$resume', '$photos', '$apply_for')";
if(mysql_query($status))
{
require_once('include/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP(); //
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Port = 25;
$mail->Username = "XXXXXX@gmail.com";
$mail->Password = "XXXXXXX";
//$mail->SMTPSecure = "ssl";
$mail->SMTPSecure = "tls";
$mail->AddAddress($email,"Guest");
$mail->SetFrom("cCXXXXXXX@gmail.com","XXXXXXXX");
$mail->Subject = "New Applicat Applyed for ".$apply_for;
$body = 'html';
$mail->MsgHTML($body);
$mail->AddAttachment("admin/upload/".$resume); // attachment
$mail->AddAttachment("admin/upload/".$photos); // attachment
if($mail->Send())
{
echo "hi";
header("Location:apply-now.php?msg=Thank you for Apply. We will be in touch with you very soon!!");
exit;
}else{
header("Location:apply-now.php?msg=We encountered an error sending your mail");
exit;
}
}
}else{
echo "dfsdfsdfsdf ";
}
?>
邮件没有发送,也没有重定向到apply-now.php页面我也用ssl 465和tls 587端口,并且在我的动作php页面上只发送重定向邮件后没有显示任何类型的错误,这段代码有什么问题请帮我 感谢
答案 0 :(得分:0)
在发送之前,我们必须修改PHPMailer对象以指示消息应该被解释为HTML。从技术上讲,消息体必须设置为multipart / alternative。这完成了:
<强> $ MAIL-&GT; IsHTML(真); 强>
有关详细信息,您可以visit here