3 Replies - 4603 Views - Last Post: 17 June 2008 - 04:28 AM Rate Topic: -----

#1 sateeshchandra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-June 08

How to send email using PHP

Posted 17 June 2008 - 02:15 AM

Hi all,

I need to send email using Php .But I am facing errors.How we can send.I need code.

<?php
	  include_once("func/database.php");
	  if(isset($_POST['btnsubmit']))
	  {
		$emailid = $_POST['txtemail'];
		$query = "select password from user where email_id='".$emailid."'";
		$result = mysql_query($query);
		$resultdata = mysql_fetch_array($result);
		$password = $resultdata['password'];
		$to = '$emailid';
		$subject = 'Muzic Darbar Response';
		$body = ".$password.";
		$headers = "From: support@motvik.com\r\nReply-To:'".$emailid."'";
		if (mail($to, $subject, $body ,$headers)) {
		echo("<p>Message successfully sent!</p>");
		 }
		 else {
		echo("<p>Message delivery failed...</p>");
			}
		header("Location:index.php?q=Password has been sent to your mailbox.");
	  }

?>



Error:
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:\xampp\htdocs\MusicDarbar\forgot_password.php on line 14

** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: How to send email using PHP

#2 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: How to send email using PHP

Posted 17 June 2008 - 02:19 AM

Do you have a mail server running on your localhost? Can you verify that it is currently running? If so, check the logs & see if the connection was refused.
Was This Post Helpful? 0
  • +
  • -

#3 sateeshchandra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-June 08

Re: How to send email using PHP

Posted 17 June 2008 - 03:16 AM

Yupp......

Now I got it...ThanQ......

View Postno2pencil, on 17 Jun, 2008 - 02:19 AM, said:

Do you have a mail server running on your localhost? Can you verify that it is currently running? If so, check the logs & see if the connection was refused.



Yupp......

Now I got it...ThanQ......

View Postno2pencil, on 17 Jun, 2008 - 02:19 AM, said:

Do you have a mail server running on your localhost? Can you verify that it is currently running? If so, check the logs & see if the connection was refused.

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: How to send email using PHP

Posted 17 June 2008 - 04:28 AM

Can you post your solution, it will help others in the future.

Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1