Page 1 of 1

PHP Mail

Posted: Thu Mar 12, 2009 10:36 am
by yasirjamal
Dear Friends,

I am new to php. I dont no how to set SMTP. i am receiving this 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 E:\Sites\Single5\starlinks\webroot\mailer.php on line 29.

Please help me to solve this problem. my code is.

Code: Select all

 
<?php
if(isset($_POST['submit'])) {
 
    $fname_field = $_POST['firstname'];
    $lname_field = $_POST['lname'];
    $city = $_POST['city'];
    $occupation = $_POST['occupation'];
    $email_field = $_POST['email'];
    $message = $_POST['message'];
    $option = $_POST['lastname'];
    $comment = $_POST['comment'];
    $telephone = $_POST['telephone'];
    $mob = $_POST['mobile'];
    $dropdown = $_POST['interstedin'];
    
    $body = "
    First Name: $fname_field\n
    Last Name: $lname_field\n
    E-Mail: $email_field\n
    Intersted In: $dropdown\n
    City : $city\n
    Occupation : $occupation\n
    Telephone : $telephone\n
    Mobile : $mob\n
    Message: $comment\n";
    
    $to = "yasir.jamal@rocketmail.com"; 
    $subject = "From DSR Website";
    $headers = "From: $fname_field\r\n";
   
    if (mail($to, $subject, $body, $headers)) {
    header ("Location: http://www.yasirjamal.com/Email sent.html");
    }
     
    } else {
    echo "blarg!";
}
?> 
 

Re: PHP Mail

Posted: Fri Mar 13, 2009 9:41 pm
by Benjamin
Contact your web hosting provider regarding this error.

Re: PHP Mail

Posted: Sat Mar 14, 2009 1:06 am
by gagan
Dear friend,

If you are trying to send mail on your localhost server. This will not work. Please upload your file in FTP first then test it . It will work.

Re: PHP Mail

Posted: Sat Mar 14, 2009 2:17 am
by php_east
you need an SMTP Server if on your local.

Re: PHP Mail

Posted: Sat Mar 14, 2009 2:28 am
by Benjamin
Forum Rules wrote: 11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
You may also what to read:
  1. General Posting Guidelines
  2. Posting Code in the Forums
  3. PHP Manual
  4. PHP Tutorials