Jump to content

sending email problem


mona
 Share

Recommended Posts

I faced the following error while trying to send an email using php:my php file is as follows:<?php$to=$_POST["email"];$password=$_POST["password"];$login=$_POST["login"];$msg="Your login and password are as follows: login Id:".$login." Password:" .$password; $from = "From: xxx@xxx.xxx<br>";if( mail ( $to, "login information", $msg, $from )) { echo "Your password was successfully sent to you<br>"; } else echo "Could not sent you an email with there password!"; ?>the error is as follows: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\Apache Group\Apache2\htdocs\xml forum project\password.php on line 9As I find I should have a local mail server on my laptop to do that:I downloaded a mail server called: Argosoft mail server and it is installed on my computerwhat should I do to make it workwhat changes should I do to my php.ini file please help!

Link to comment
Share on other sites

no no no no... port it fine (if you have the router send port 25 to the server!!!)I had the same problem:look at:sendmail_from = user@domain.comsendmail_from = user@domain.com ; for Win32 onlymake sure you have a space before and after the =other wise what are you on? Windows? What version? Server 2000?

Link to comment
Share on other sites

the mail function should look like this:

<?php$to = $_POST['email'];$password = $_POST['password'];$login = $_POST['login'];$msg = "Your login and password are as follows:<br/>Login Id: " . $login . "<br/>Password: " . $password;// To send HTML mail, the Content-type header must be set$headers  = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";// Additional headers$headers .= 'To: Mary <mary@example.com>' . "\r\n";$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";if (mail($to, "login information", $msg, $headers)) { echo "Your password was successfully sent to you<br/>";} else { echo "Could not send you an email with your password!";};?>

obliviously, the addresses in the headers need some adjustment, but that should fix that up. Having that "<br>" in the $from when thats being put into that part of the mail function was no good.also, if you get errors or dont receive the email, the "\r\n" should be changed to "\n", as some servers like that better.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...