PHP Mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yasirjamal
Forum Newbie
Posts: 8
Joined: Tue Feb 10, 2009 11:05 pm

PHP Mail

Post 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!";
}
?> 
 
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHP Mail

Post by Benjamin »

Contact your web hosting provider regarding this error.
gagan
Forum Newbie
Posts: 10
Joined: Fri Jan 30, 2009 5:03 am

Re: PHP Mail

Post 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.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: PHP Mail

Post by php_east »

you need an SMTP Server if on your local.
Last edited by php_east on Sat Mar 14, 2009 3:33 am, edited 1 time in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHP Mail

Post 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
Post Reply