使用phpmailer未收到邮件 [英] Mail not received using phpmailer

查看:61
本文介绍了使用phpmailer未收到邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用过phpmailer自动加载,但是当表单在感谢页面上提交完全重定向但我没有收到任何邮件。我试过以下代码:



我尝试过:



i have used phpmailer autoload but when form submitted its redirect perfectly on thank you page but i did not get any mail. i have tried below code:

What I have tried:

MY Code:

<?php	

//include_once 'dbconfig.php';

require 'email/phpmailer/PHPMailerAutoload.php';

//set validation error flag as false
$error = false;

//check if form is submitted
	
	if(isset($_POST['submit'])){		
		
		$name = $_POST['name'];
		$location = $_POST['location'];
		$email = $_POST['email'];
		$mobile = $_POST['mobile'];
		$msg = $_POST['mssge'];
		
		if(empty($name)){
			$error = true;			
			?>
				<script>
					alert('Please Enter Your Name.');
					window.location.href='wonder_women.php';
				</script>
			<?php
		}		
		elseif (!preg_match("/^[a-zA-Z ]+$/",$name)) {
			$error = true;			
			?>
				<script>
					alert('Name must contain only alphabets and space.');
					window.location.href='wonder_women.php';
				</script>
			<?php
		}
		elseif(empty($location)){
			$error = true;			
			?>
				<script>
					alert('Please Enter Your Location.');
					window.location.href='wonder_women.php';
				</script>
			<?php
		}	
		elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)) {
			$error = true;			
			?>
			<script>
				alert('Please Enter Valid Email ID.');
				window.location.href='wonder_women.php';
			</script>
			<?php
		}
		elseif(empty($mobile)){
			$error = true;			
			?>
				<script>
					alert('Please Enter Your Mobile Number.');
					window.location.href='wonder_women.php';
				</script>
			<?php
		}	
			
    
		if (!$error) {			
			$mail = new PHPMailer;			
			$mail->setFrom('myemailid@gmail.com','myemailid');
			$mail->addAddress('myanmeemail128@gmail.com');     // Add a recipient			
			$mail->isHTML(true);                                 // Set email format to HTML
			$mail->Subject = 'Wonder Women Feedback';
			$mail->Body =
				"<p>Name : $name</p>
							<p>Location : $location</p>
							<p>Email : $email</p>
							<p>Mobile : $mobile</p>
							<p>Message : $msg</p>";
			if ($mail->send()) {
				?>
					<script>
						alert('Thank You.');
						window.location.href='wonder_women.php';
					</script>					
				<?php
			}
			else{					
				?>
					<script>
						alert('Error in submiting Story');
						window.location.href='wonder_women.php';
					</script>
				<?php
			}
		}
		
	}
	
?>

推荐答案

错误 = false;

// 检查表单是否已提交

if(isset(
error = false; //check if form is submitted if(isset(


_POST [' submit'] )){

_POST['submit'])){


name =
name =


这篇关于使用phpmailer未收到邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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