<?php
session_cache_limiter( 'nocache' );
error_reporting(0);
header( 'Expires: ' . gmdate( 'r', 0 ) );
header( 'Content-type: application/json' );
$to = 'niamul@uiCookies';
$email_template = 'simple.html';
$subject = strip_tags($_POST['subject']);
$email = strip_tags($_POST['email']);
$url = strip_tags($_POST['url']);
$name = strip_tags($_POST['name']);
$organization = strip_tags($_POST['organization']);
$position = strip_tags($_POST['position']);
$country = strip_tags($_POST['country']);
$message = nl2br( htmlspecialchars($_POST['message'], ENT_QUOTES) );
$result = array();
if(empty($name)){
$result = array( 'response' => 'error', 'empty'=>'name', 'message'=>'<strong>Error!</strong> Name is empty.' );
echo json_encode($result );
die;
}
if(empty($email)){
$result = array( 'response' => 'error', 'empty'=>'email', 'message'=>'<strong>Error!</strong> Email is empty.' );
echo json_encode($result );
die;
}
if(empty($message)){
$result = array( 'response' => 'error', 'empty'=>'message', 'message'=>'<strong>Error!</strong> Message body is empty.' );
echo json_encode($result );
die;
}
$headers = "From: " . $name . ' <' . $email . '>' . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$templateTags = array(
'{{subject}}' => $subject,
'{{email}}'=>$email,
'{{message}}'=>$message,
'{{name}}'=>$name,
'{{url}}'=>$url,
'{{organization}}'=>$organization,
'{{position}}'=>$position,
'{{country}}'=>$country
);
$templateContents = file_get_contents( dirname(__FILE__) . '/email-templates/'.$email_template);
$contents = strtr($templateContents, $templateTags);
if ( mail( $to, $subject, $contents, $headers ) ) {
$result = array( 'response' => 'success', 'message'=>'<strong>Success!</strong> Mail Sent.' );
} else {
$result = array( 'response' => 'error', 'message'=>'<strong>Error!</strong> Cann\'t Send Mail.' );
}
echo json_encode( $result );
die;
DTcode7
- 粉丝: 3w+
- 资源: 4986
最新资源
- StudentAffairs-javaEE框架项目资源
- lm-sensors-libs-3.4.0-8.20160601gitf9185e5.el7-9.1.x64-86.rpm.tar.gz
- 创创猫java社区团购商城-社区运营如橙心优选-java开发项目资源
- lm-sensors-sensord-3.4.0-8.20160601gitf9185e5.el7-9.1.x64-86.rpm.tar.gz
- lockdev-1.0.4-0.13.20111007git.el7.x64-86.rpm.tar.gz
- 大学生活动社交小程序-活动资源
- lockdev-devel-1.0.4-0.13.20111007git.el7.x64-86.rpm.tar.gz
- CC活动报名小程序-活动资源
- jonquimbly-shap-e-机器学习开发资源
- log4cxx-0.10.0-16.el7.x64-86.rpm.tar.gz
- Trajectory_add_core-matlab仿真资源
- log4cxx-devel-0.10.0-16.el7.x64-86.rpm.tar.gz
- kis-flow-活动资源
- Eazax-Kit Cocos 游戏开发工具包-cocos资源
- Remote WOL MicroPython-硬件开发资源
- log4j-1.2.17-18.el7-4.x64-86.rpm.tar.gz
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈