LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2012, 11:53 AM   #1
nothing07
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Rep: Reputation: Disabled
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:"


I cant send a confirmation email with XAMPP, i think it has the PHP 5.3.0. i have tried to read about it in other forums, but there answers didn't work for me. I can start with the php.ini

php.ini
Code:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\php\logs\php_mail.log"
and the error message is:
Code:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\Skynet\registrationcheck.php on line 37
here is the registrationcheck.php
Code:
<?php
require('connecttodatabase.php'); //connect to database

$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['password']);
$repeat_password = strip_tags($_POST['repeat-password']);

//test to see if name only contains letters
if(!preg_match(("[^A-Za-z ]"),$name))
{
	//remember to make one for "too long name"
	
	//check if email in use
	
	$checkemailcommand="SELECT * FROM users WHERE email = '$email'";
	$checkemailresult = mysql_query($checkemailcommand);
	$num=mysql_num_rows($checkemailresult);

	if($num==0){
	
		//if passwords match up (should do it for email to but it ist done)
		 if($password==$repeat_password){
		 
			//we generate random code for confirmation email
			$confirm_code=md5(uniqid(rand()));
			
			//then we insert their info in a temporary database
			$insertinfocommand="INSERT INTO temp SET code='$confirm_code', name = '$name', email = '$email', password = '$password'";
			$insertinforesult=mysql_query($insertinfocommand);
			
			//if the info is succsesfully entered temp, we are going to send an email
			if($insertinforesult){
				
				$message = "Your Confirmation link: \r\n http://redboook.netii.net/confirmation.php?passkey=$confirm_code";  //link to the confirmation page where the var passkey is the same as their code
				
				$sendmail = mail("$email","Redbook confirmation code","$message");
				
				echo "confirmation link have been sent to your email ".$email;
			}else{
			echo "couldn't find your email in our database";
			}
		 
		 		 }else{
		 echo "password doesn't match";
		 //header("Location:passworddoesntmatch.html")
		 }
		 
	}else{
	echo "email in use";
	//header("Location:alreadyregistered.html");
	}
	
}else{
echo "invalid name";
//header("Location:invalidname.html");
}



?>
if you need to see the confirmation.php here is it
Code:
<?php
require('connecttodatabase.php'); //connect to database

$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['password']);
$repeat_password = strip_tags($_POST['repeat-password']);

//test to see if name only contains letters
if(!preg_match(("[^A-Za-z ]"),$name))
{
	//remember to make one for "too long name"
	
	//check if email in use
	
	$checkemailcommand="SELECT * FROM users WHERE email = '$email'";
	$checkemailresult = mysql_query($checkemailcommand);
	$num=mysql_num_rows($checkemailresult);

	if($num==0){
	
		//if passwords match up (should do it for email to but it ist done)
		 if($password==$repeat_password){
		 
			//we generate random code for confirmation email
			$confirm_code=md5(uniqid(rand()));
			
			//then we insert their info in a temporary database
			$insertinfocommand="INSERT INTO temp SET code='$confirm_code', name = '$name', email = '$email', password = '$password'";
			$insertinforesult=mysql_query($insertinfocommand);
			
			//if the info is succsesfully entered temp, we are going to send an email
			if($insertinforesult){
				
				$message = "Your Confirmation link: \r\n http://redboook.netii.net/confirmation.php?passkey=$confirm_code";  //link to the confirmation page where the var passkey is the same as their code
				
				$sendmail = mail("$email","Redbook confirmation code","$message");
				
				echo "confirmation link have been sent to your email ".$email;
			}else{
			echo "couldn't find your email in our database";
			}
		 
		 		 }else{
		 echo "password doesn't match";
		 //header("Location:passworddoesntmatch.html")
		 }
		 
	}else{
	echo "email in use";
	//header("Location:alreadyregistered.html");
	}
	
}else{
echo "invalid name";
//header("Location:invalidname.html");
}



?>
i will appreciate anykind of respond. and i can also tell you that i ave checked the database and everything is fine. when i upload the files to 000webhost everything works fine, but for several reasons i like to use XAMPP localhost.

if there is some information you want to know about the script or something like that I can post that up too. if you didn't understand something just let me know and I'll try to explain it.

Last edited by nothing07; 06-22-2012 at 11:57 AM.
 
Old 06-22-2012, 02:56 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Change this part of your php.ini:

Code:
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
To this:

Code:
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = youremail@yourdomain.com
 
Old 06-22-2012, 02:57 PM   #3
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Also, you could update your php file with the $sendmail function to specify a return address.


Code:
If you would like to add From : email address

Use code as follows:

<?php
$to      = 'user@domain.com';
$subject = 'Subject';
$message = 'This is a test';
$headers = 'From: webmaster@yourdot.com' . "\r\n" .
   'Reply-To: webmaster@yourdot.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl: how to save an e-mail attachment on disk keeping the "&" character (no "%26"!!) d1s4st3r Programming 5 09-29-2010 09:30 PM
Command "mail" returns "panic: temporary file seek" kenneho Linux - Software 5 12-23-2008 03:27 AM
How might I restore kmail folders/mail/settings from a "badly" saved "home"? deh6 Linux - Software 5 03-08-2008 09:25 PM
"URGENT" Re: mail() function on new server newladder Programming 8 05-22-2007 11:34 AM
"local mail function" belorion Linux - General 0 09-29-2005 09:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration