need help with mail()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

need help with mail()

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Is the SMTP server running?
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post 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.
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post 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
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

Post by beckbapegeneral »

aint the smtp server my apache :?:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Post Reply