Jump to content

Mail script not working


Vivid Lust

Recommended Posts

Hey all!

 

I made this mail script, although not receiving any emails, help appreciated!

 

<?php

//connect to mysql
$link = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

//connect to db
mysql_select_db($dbname,$link) or die ('Error connecting to mysql') or die(mysql_error());

$mail = $_POST['email'];
$sub = $_POST['subject'];
$msg = $_POST['message'];

//get info about user from database
$sql = "SELECT * FROM exchange WHERE id=( \"$id\" )";
$query=mysql_query($sql, $link)
or die(mysql_error());
while($row=mysql_fetch_assoc($query)){
$user_email       =  $row['email'];
}

   if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
   	if( $mail == "" || $sub == "" || $msg == ""){
   		header('location:email.php?msg=2&id='.$id);
   		exit;
   	}
   	

//define the receiver of the email
$to = $user_email;
//define the subject of the email
$subject = $sub;
//define the message to be sent. Each line should be separated with \n
$message = $msg;
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: ".$mail."\r\nReply-To: ".$mail;
//send the email
mail($to, $subject, $message, $headers, "-f$e");
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
header("Location:success2.php");

}else{
header('location:email.php?msg=1&id='.$id);
}
unset($_SESSION['security_code']);
?>

Thanks for any help.

Link to comment
https://forums.phpfreaks.com/topic/131529-mail-script-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.