网站中的联系表格未收到电子邮件 [英] Contact form in website is not receiving email

查看:93
本文介绍了网站中的联系表格未收到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,



我已添加以下代码以便在php中发送邮件。但我没有收到任何来自联系表格的邮件。



Sir,

I have added the below code to send mail in php. But i didnt received any mail from contact form.

<?php 
$errors = '';
$myemail = 'sukirti@domain.in';//<-----Put Your email address here.
$host = "smtp.domain.in";
 $myemail = "sukirti@domain.in";
 $password = "*********";
if(empty($_POST['userName'])  || 
   empty($_POST['userEmail']) || 
   empty($_POST['userMsg']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['userName']; 
$email_address = $_POST['userEmail']; 
$message = $_POST['userMsg']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
	$to = $myemail; 
	$email_subject = "Contact form submission: $name";
	$email_body = "You have received a new message. ".
	" Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message"; 
	
	$headers = "From: $myemail\n"; 
	$headers .= "Reply-To: $email_address";
	
	mail($to,$email_subject,$email_body,$headers);
	//redirect to the 'thank you' page
	header('Location: index.html');
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>


</body>
</html>













请帮忙。







Please help on this.

推荐答案

错误 = ' ';
errors = '';


myemail = ' sukirti@domain.in'; // < -----将您的电子邮件地址放在此处。
myemail = 'sukirti@domain.in';//<-----Put Your email address here.


host = smtp.domain.in;
host = "smtp.domain.in";


这篇关于网站中的联系表格未收到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆