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 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mail() : correct me where i am wrong??

    hello
    i am just getting into php coding !
    i want to have one astromatch form and the details filled should be sended to particular email !
    i tried but emailing is not working ! means i am not able to recieve email ! where i am wrong ! what should i change please help me regarding this !
    here is the code !

    astromatch.php

    Code:
        <?php
        if ( !defined( 'SMARTY_DIR' ) ) {
        include_once( 'init.php' );
        }
        $cmd = $_POST['cmd'];
        if ( $cmd == 'posted' ){
    
        $name = trim($_POST['name']);
        $id = trim($_POST['id']);
        $email = trim($_POST['email']);
        $*** = trim($_POST['***']);
        $dob = trim($_POST['dob']);
        $bp = trim($_POST['bp']);
        $bt = trim($_POST['bt']);
        $pname = trim($_POST['name']);
        $pid = trim($_POST['id']);
        $pemail = trim($_POST['email']);
        $pdob = trim($_POST['dob']);
        $pbp = trim($_POST['bp']);
        $pbt = trim($_POST['bt']);
        $comments = trim($_POST['comments']);
    
        $To ="manu_ghimire@yahoo.com";
    
        $success= mailSender($To, $name, $id, $email, $***, $dob, $bp, $bt, $pname, $pid, $pemail, $pdob, $pbp, $pbt,"From: $email");
    
        $t->assign( 'success', $success );
        }
    
        $t->assign('rendered_page', $t->fetch('astromatch.tpl') );
    
        $t->display( 'index.tpl' );
        exit;
        ?>
    astromatch.tpl

    Code:
    <form action="" method="post">
    
        <input type="hidden" name="cmd" value="posted"/>
        <table border="0" cellspacing="2">
        <tr><p align="left"><b> Your Information</b> </p></tr>
        <tr><td>Full Name</td><td><input type="text" size="30" name="name"></td></tr>
        <tr><td>Grihasta.com Id</td><td><input type="text" size="30" name="id"></td></tr>
        <tr><td>Email</td><td><input type="text" size="30" name="email"></td></tr>
        <tr><td>***</td><td><input type="text" size="30" name="***"></td></tr>
        <tr><td>Date of Birth</td><td><input type="text" size="30" name="dob"></td></tr>
        <tr><td>Birth Place</td><td><input type="text" size="30" name="bp"></td></tr>
        <tr><td>Birth Time</td><td><input type="text" size="30" name="bt"></td></tr>
        <table border="0" cellspacing="2">
        <tr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<tr>
    
        <tr><b> Prospective Partner Information</b></tr>
        <tr><td>Full Name</td><td><input type="text" size="30" name="pname"></td></tr>
        <tr><td>Grihasta.com Id</td><td><input type="text" size="30" name="pid"></td></tr>
        <tr><td>Email</td><td><input type="text" size="30" name="pemail"></td></tr>
        <tr><td>Date of Birth</td><td><input type="text" size="30" name="pdob"></td></tr>
        <tr><td>Birth Place</td><td><input type="text" size="30" name="pbp"></td></tr>
        <tr><td>Birth Time</td><td><input type="text" size="30" name="pbt"></td></tr>
        <tr><td valign="top">Comments</td><td><textarea name="comments" rows="6" cols="25"></textarea></td></tr>
        <tr><td>&nbsp;</td><td><input type="submit" name="cmd" value="send"><font face="arial" size="1">&nbsp;&nbsp;<a href=""></a></font></td></tr>
        </table>
        </form>
        ?>
    sir please guide me where i am getting wrong

    and also one of my question is ! is it so that only 3 fields(email,subject,message,from) can be send ! no other like i done

    thanx in advance for paying attention !
    manughimiye
    neps

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    PHP Sendmail basically looks for these things (in blue).
    The variable names are not important, but the placement is.

    $extraheaders = "From: $sender\nReply-To: $sender\n\n";

    if (! mail($toaddr, $subject, $message, $extraheaders))
    echo "Mail did not send for some reason.";

    So, you need to put all of your email content variables into a $message variable ... you can add other text as well (but no double quotes). The email message will follow the line breaks also, so you'll see it as is ....

    $message="
    Here is the email from the form:
    ======================================
    Date of birth: $dob
    whatever: $bp
    whatever: $bt, $pname, $pid, $pemail, $pdob, $pbp, $pbt
    ======================================

    ";

    EDIT:
    Also, when testing, make sure any emails you are sending to yourself (for testing) are
    not ending up in your "bulk" email box (or spam box). Some email filters might be
    flagging your emails. It all depends on who the sender is, the subject line, and the
    headers your webhost might place on the emails.


    .
    Last edited by mlseim; 03-26-2007 at 01:56 PM.


  •  

    Posting Permissions

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