2

Possible Duplicate:
how to test php email using WAMP

Hey everyone,

First off I am new to PHP and webmail service. Please forgive me if I overlook anything important.

I have a downloads page, when clicked must redirect to a different page to collect user data (email,name). After the form has been filled I want to redirect him to complete his download.

this is the php code for the mail page collects and sends data

<?php  

$name = $_POST['name_first'];  
$mail = $_POST['email'];  
$number = $_POST['phone_number'];

echo "Name : $name";    

echo '<br>';

echo "Email-ID : $mail"; 

echo '<br>';

echo "Phone-Number : $number";   

$email_message = "first name: {$name} email is {$mail} number is {$name} ";

mail('vinoth.33@gmail.com', 'Form Response', $email_message);

?>

mail() function is not working giving me an error saying that smtp port is not configured, although after taking some advice from the forums and configuring php.ini...it still seems to not work.

This is the actual error I am getting please help. Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Community
  • 1
  • 1
  • And what part of `verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()` didn't you understand? – wimvds May 05 '11 at 13:01

2 Answers2

1

try this it may help help you.

  • Open the "php.ini". For XAMPP,it is located in C:XAMPPphpphp.ini. Find out if you are using WAMPP server.
  • Search [mail function] in the php.ini file.

    You can find like below. [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. sendmail_from = me@localhost.com

  • Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25. Change sendmail_from from me@localhost.com to your domain email address which will be used as from address..
  • So for me, it will become like this. [mail function] ; For Win32 only. SMTP = smtp.yourdomain.com smtp_port = 25 ; For Win32 only. sendmail_from = info@yourdomain.com
  • Restart the XAMPP or WAMP(apache server) so that changes will start working.
  • Now try to send the mail using the mail() function , hope this will work for you.
NewUser
  • 12,713
  • 39
  • 142
  • 236
  • 1
    thanks was able to get it working..the mailer works properly...now I need to put up a loop to check if any field is empty in the form –  May 06 '11 at 06:10
  • hey Vinner if my answer helped you than just make a vote for me by clicking the uparrow beside my answer and for your problem is concerned for checking empty field you can use if else condition otherwise you can use array for checking blank fields. – NewUser May 06 '11 at 16:40
1

To send email I always use phpmailer. And I configure it to use my provider's smtp server or gmail smtp server.

That works like a charm and doesn't depend on your server mail setup.

dwarfy
  • 3,076
  • 18
  • 22
  • thanks for the info about gmail's server...was able to run in it without issues –  May 06 '11 at 06:11