I'm trying to send a confirmation email to the person who submitted this "ticket" but it's not sending. I know the right info is there it just seems like I'm putting something in the wrong spot.

Anyone help me out?

<?php
include("database.php");

$today = date("M d Y"); 

$sql="INSERT INTO info (Ticket, Dateadded, Name, Email, Issue, Cat, Descript, Trouble, Device, Priority)
VALUES
('$_POST[ticket]','$today','$_POST[name]','$_POST[email]','$_POST[issue]','$_POST[cat]','$_POST[descript]','$_POST[trouble]','$_POST[device]','$_POST[priority]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
else 
	{
$query  = "SELECT ticket, dateadded, name, email, issue, descript, cat, device, trouble, priority FROM info ORDER by ticket DESC LIMIT 1";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo "<div class=\"thankyou\"><p>{$row['name']},</p><p>Thank you for submitting a request to get this issue resolved. Your ticket # is <b>{$row['ticket']}</b>. You will be notified by email if we need any more information or when we've fixed this issue.</p><br />" .
    	"<p>-Support Team</p></div>";
	}
} 

$to = "{$row['email']}@example.com";
$subject = "Support - {$row['cat']} - Ticket #{$row['ticket']}";
$message = "Hello {$row['name']},\n\n Thank you for submitting a request to get this issue resolved. Your ticket # is {$row['ticket']}. You will be notified by email if we need any more information or when we've fixed this issue.\n\n-Support Team";
$from = "IT@group.example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);	


mysql_close($con)
?>

Debug all variables of line 31. Probably you'll find that $to contains two domain names - one which the user entered and one ('example.com') which your program added.

Member Avatar for Zagga

As smantscheff pointed out, line 26 it taking the email address value from the database and adding @example.com to the end of it. Does the users full email address get stored in the database or just the first part?


Zagga

As smantscheff pointed out, line 26 it taking the email address value from the database and adding @example.com to the end of it. Does the users full email address get stored in the database or just the first part?


Zagga

Thanks for the replies. I just store the first part of the email address in the database. Any other suggestions? I'm thinking that the mail() part is in the wrong bracket. Could this affect if it was executed?

Figured it out.. had it in the wrong spot. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.