954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php email script not sending - wrong order?

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>" .
    	"<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)
?>
devinodaniel
Light Poster
47 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

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.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

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

Zagga
Posting Whiz in Training
257 posts since Dec 2009
Reputation Points: 22
Solved Threads: 54
 

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?

devinodaniel
Light Poster
47 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

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

devinodaniel
Light Poster
47 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

You can refer to the script in http://top-answers.net/webhost/web-hosting.html
to send mails through PHP..

dineshsjce
Newbie Poster
4 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: