Page 1 of 1

need help with mail()

Posted: Wed May 31, 2006 11:11 am
by beckbapegeneral
someone please help me with the configuring of my smtp server. thanks alot.

Code: Select all

if ($_POST["custEmail"] != "")
{
  	$ticketNo = $_POST["ticketNo"];
  	$custname = $_POST["custName"];
  	$custemail = $_POST["custEmail"];
  	$subject = $_POST["subject"];
  	$content = $_POST["content"];
  	$department = $_POST["department.clicked"];
	$to = $_POST["custEmail"];
	$subject = "Toshiba Service Center";
	$message = "
	<html>
	<head></head>
	<body>
	Hi ".$custname."
	<p>
	Your problem has been referred to the respective department. This email contains your ticket number. If you have any enquiry, feel free to call us with your ticket number. Your ticket number is as shown below:
	<br>
	<strong>Ticket Number: ".$ticketNo."</strong>
	<p>
	Thanks & Regards,<br>
	Toshiba Service Center";
	$from = "hr@toshiba.com.sg";
	$headers = "From: cs@toshiba.com.sg\nReply-To: cs@toshiba.com.sg\nContent-Type: text/html; charset=iso-8859-1";
	
	mail($to, $subject, $message, $headers);
	echo "
	<center>
	<form action=pms.php method=Post>
	<table width=100% border=0 cellpadding=4 cellspacing=0>;
	<tr>
		<td><Strong>Email sent.</strong></td>
	</tr>
	<tr>
		<td><input type=submit value=Done src=pms.php /></td>
	</tr>
	</table>
	</form>
	</center>";
}
else
{
  	echo "
	<center>
	<form action=pms.php method=Post>
	<table width=100% border=0 cellpadding=4 cellspacing=0>
	<tr>
		<td><Strong>Email not sent. Please click on the back button to go back to the form.</strong></td>
	</tr>
	<tr>
		<td><input type=submit value=Back src=pms.php /></td>
	</tr>
	</table>
	</form>
	</center>";
}
?>

Code: Select all

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\xampp\htdocs\pmsDone.php on line 35
;
Email sent.

Posted: Wed May 31, 2006 12:44 pm
by Chris Corbyn
Is the SMTP server running?

Posted: Wed May 31, 2006 3:04 pm
by ok
First of all, you have a syntex error in the header ("\r\n" instead of "\n");
Secondly, follow the instructions in the php manual in the mail function: http://www.php.net/mail.

Posted: Wed May 31, 2006 3:45 pm
by aerodromoi
Just a quick note:
You don't seem to validate the user input. I'd say this is a bit risky as you don't know
what some people might take for their email address ;)

btw: Why do you have a $from variable if the "from" is hardcoded into the header?

aerodromoi

Posted: Wed May 31, 2006 6:36 pm
by beckbapegeneral
aint the smtp server my apache :?:

Posted: Thu Jun 01, 2006 2:25 am
by Chris Corbyn
beckbapegeneral wrote:aint the smtp server my apache :?:
No thats the HTTP server. The SMTP server would be something like qMail, Postfix or Exim. Do you have an SMTP server with your ISP? The one you set your mail client up to send from.