Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem Sending email in php

    why the following email sending php form not working:

    <?php
    if (isset($_REQUEST['email']))
    //if "email" is filled out, send email
    {
    //send email
    $email = $_REQUEST['email'] ;
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['message'] ;
    mail("sayedbd2012@gmail.com", $subject,
    $message, "From:" . $email);
    echo "Thank you for using our mail form";
    }
    else
    //if "email" is not filled out, display the form
    {
    echo "<form method='post' action='mailform.php'>
    Email: <input name='email' type='text' /><br />
    Subject: <input name='subject' type='text' /><br />
    Message:<br />
    <textarea name='message' rows='15' cols='40'>
    </textarea><br />
    <input type='submit' />
    </form>";
    }
    ?>

    i made changes in php.ini file: smtp: 'my smtp server' port: 25

    but mail not sending....

    anybody can help me?

    Anam

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I don't know if my script below will be any different.
    Try putting email() function in an "if" statement to allow PHP time to process it.

    PHP Code:
    <?php

    if (isset($_REQUEST['email'])){
    //if "email" is filled out, send email

    //send email
    $email $_REQUEST['email'] ;
    $subject $_REQUEST['subject'] ;
    $message $_REQUEST['message'] ;

    // send email
    if(mail("sayedbd2012@gmail.com"$subject$message"From:" $email)){
    echo 
    "Thank you for using our mail form";
    exit;
    }
       else{
       echo 
    "Email did not send for some reason";
       exit;
       }
    }
    else{
    //if "email" is not filled out, display the form

    echo "<form method='post' action='mailform.php'>
    Email: <input name='email' type='text' /><br />
    Subject: <input name='subject' type='text' /><br />
    Message:<br />
    <textarea name='message' rows='15' cols='40'>
    </textarea><br />
    <input type='submit' />
    </form>"
    ;
    }
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •