Page 1 of 1

mail system doesn't work? SMTP and port 25?

Posted: Thu Aug 11, 2011 1:53 pm
by Jackount
Hi there. It's me with the viewtopic.php?f=1&t=130994&p=657913#p657913...

anyway, got the automatic mailing system working... besided getting this error message: (Still running on localhost)

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:\xampp\htdocs\Hjemmeside\register.php on line 46
WHAT!? All tutorials, really EVERYONE, i found on the internet, tells me nothing about this? What is this?
I HAVE googled how to change that php.ini, and I know what the file does, and I've tried to edit it, but nothing helps...

Here's the referred register.php file (only interesting part of it):

Code: Select all

		if ($num == 0){
			//duplicate emails
			$query2 = "SELECT * FROM users WHERE email ='$_POST[email]'";
			$result2 = mysql_query($query2);
			$num2 = mysql_num_rows($result2);
			
			if ($num2 == 0) {
				//Passwords and emails matching?
				if ($_POST['password'] != $_POST['password2']) {
					error("Kodeordene er ikke ens.");}
				if ($_POST['email'] != $_POST['email2']) {
					error("Email-adresserne er ikke ens.");}
				
				$confirm_code = md5(uniqid(rand())); //random conf. code
				//rid of html from hackers
				$name = strip_tags($_POST['username']);
				$email = strip_tags($_POST['email']);
				$pass = strip_tags($_POST['password']);				
				//Insert to DB
				$sql = "INSERT INTO temp SET code='$confirm_code', username='$name', email='$email', password='$pass'";
				$result = mysql_query($sql);
				
					if ($result) {
						$message = "<b>Din aktiveringskode</b> \r\n";
						$message.= "Klik på linket for at aktivere din bruger: \r\n";
						$message.= "<a href:'http://localhost/Hjemmeside/confirmation.php?passkey=".
							$confirm_code."'>http://localhost/Hjemmeside/confirmation.php?passkey=".$confirm_code."</a>";
						
						$headers = "MIME-Version: 1.0" . "\r\n";
						$headers.= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
						$headers.= "From:metallicarules@live.dk";
						
						$sentmail = mail($email, "Oprettelse af bruger", $message, $headers); // -------- LINE 46 --------------- //
					} else {
						echo "E-mail ikke fundet i databasen.";
					}
					
					if ($sentmail) {
						echo "En aktiveringskode er blevet sendt til din mail";
					} else {
						echo "Kunne ikke sende aktiveringskoden.";
					}
			} else {
				echo "E-mail allerede i brug";
			}
nevermind all the danish sentences.... I wouldn't bother to translate em..

I sincerely hope anyone can help me out with this.
Thanks in advance. :)

Re: mail system doesn't work? SMTP and port 25?

Posted: Thu Aug 11, 2011 4:10 pm
by social_experiment
Did you edit this php.ini file ? - \xampp\php\php.ini

These two url might be enlightning.
xampp
sending-e-mail-from-localhost-in-php-in-windows-environment.html

Hth.

Re: mail system doesn't work? SMTP and port 25?

Posted: Thu Aug 11, 2011 4:25 pm
by Jackount
Yep, that file.

Thanks, the second link helped a lot.
Just one thing left, though:
"you can find the line “SMTP=localhost“. change the localhost to the smtp server name of your ISP"
ehm... kinda embarrasing, but what is ISP, and how do I know the smtp server name of it? ... :)

Re: mail system doesn't work? SMTP and port 25?

Posted: Thu Aug 11, 2011 4:30 pm
by social_experiment
ISP is internet service provider