Results 1 to 9 of 9

Thread: Problem using PHP Mail form

  1. #1
    Join Date
    Nov 2006
    Location
    San Luis Potosí, México
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem using PHP Mail form

    Hi,

    recently I include in one of my sites a Email form en PHP Code, but the problem is when I try to run the emailform.php a windows appears with the code but not the form, and doesn´t works.

    Please help me, I think the PHP code is not initalizated, please let me know how can I solve this problem.

    Mi hosting server has a Linux OS and I am using Dreamweaver as mi pages Editor.

    Thanks for your support,

    Eduardo Cazares

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    can you provide the code for checking out that?

    check you have PHP starting tag and closing tag in place.

  3. #3
    Join Date
    Nov 2006
    Location
    San Luis Potosí, México
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks CodeExploiter

    The code I was to use in my pages is yours, in a Post that I View you post a Demo with the form code an I try to use it, but doesn´t work in my page, I´m new in Web development but I want to solve this problem to go for the next code and learn.

    The code is ...

    <?php

    //Check whether the submission is made
    if(isset($hidSubmit)){

    //Declarate the necessary variables
    $mail_to=$txtEmailto;
    $mail_from=$txtEmailfrm;
    $mail_sub=$txtSub;
    $mail_mesg=$txtMsg;

    //Check for success/failure of delivery
    if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from"))
    echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>";
    else
    echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>";
    }
    ?>

    <form name="frmsendmail" method="post" action="" onSubmit="return ValidationForm()">
    <table width="100%" border="0">
    <tr>
    <td width="33%" align="right" class="text">Para :
    <td width="67%"><input name="txtEmailto2" type="text" class="input" id="txtEmailto22" size="30" maxlength="100">
    </tr>
    <tr>
    <td align="right" class="text">De :
    <td><input name="txtEmailfrm2" type="text" class="input" id="txtEmailfrm22" size="30" maxlength="100">
    </tr>
    <tr>
    <td align="right" class="text">Titulo :
    <td><input name="txtSub2" type="text" class="input" id="txtSub22" size="30" maxlength="100">
    </tr>
    <tr>
    <td align="right" class="text">Descripción :
    <td><textarea name="txtMsg" cols="50" rows="10" class="input" id="textarea"></textarea>
    </tr>
    <tr>
    <td align="right"><input name="hidSubmit" type="hidden" id="hidSubmit" value="true">
    <input name="Submit" type="submit" class="input" value="Enviar">
    <td><input name="Submit2" type="reset" class="input" value="Limpiar">
    </tr>
    </table>
    </form>

    Thanks

    Eduardo Cazares

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    1. Check whether you've specified your SMTP server in php.ini file

    2. Make sure that you've mentioned the correct port of your SMTP server in php.ini file

    Plz check the attached image which is the one from the php.ini file where the SMTP server settings must be done.

  5. #5
    Join Date
    Nov 2006
    Location
    San Luis Potosí, México
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default About the code

    I try to use the code in a new window and when I put all the fields and try to send appears the next message ...

    No recipient addresses found in header E-mail has been sent successfully from to

    Maybe you cand see directly in your browser, the path is ...

    http://www.quickadservers.com/formulario.php

    Thanks for your support

    Eduardo Cazares

  6. #6
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    PHP Code:
    <?php

    //Check whether the submission is made
    if(isset($_POST['hidSubmit']))
    {
    //Declarate the necessary variables
    $mail_to $_POST['txtEmailto'];
    $mail_from $_POST['txtEmailfrm'];
    $mail_sub $_POST['txtSub'];
    $mail_mesg $_POST['txtMsg'];

    //specify your SMTP server name here; for ex i've mentioned mail.yoursmtpserver.com replace it with yours
    ini_set("SMTP","mail.yoursmtpserver.com"); 

    //Check for success/failure of delivery
    if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from"))
    echo 
    "<span>E-mail has been sent successfully from $mail_sub to $mail_to</span>";
    else
    echo 
    "<span>Failed to send the E-mail from $mail_sub to $mail_to</span>";
    exit;
    }
    ?>

    <form name="frmsendmail" method="post" action="">
    <table width="100%" border="0">
    <tr>
    <td width="33%" align="right">To :
    <td width="67%"><input name="txtEmailto" type="text" size="30" maxlength="100">
    </tr>
    <tr>
    <td align="right">From :
    <td><input name="txtEmailfrm" type="text" size="30" maxlength="100">
    </tr>
    <tr>
    <td align="right">Subject :
    <td><input name="txtSub" type="text" size="30" maxlength="100">
    </tr>
    <tr>
    <td align="right">Message :
    <td><textarea name="txtMsg" cols="50" rows="10"></textarea>
    </tr>
    <tr>
    <td align="right"><input name="hidSubmit" type="hidden" value="true">
    <input name="Submit" type="submit"value="Send">
    <td><input name="Submit2" type="reset" value="Reset">
    </tr>
    </table>
    </form>

    Code:
    ini_set("SMTP","mail.yoursmtpserver.com");
    Please specify your smtp server here if you haven't mentioned that in your php.ini file.

    After that use the above code for sending mails

    I think i've posted a coding without testing it sorry about that. This one i've tested using my mail server it is sending mail

  7. #7
    Join Date
    Nov 2006
    Location
    San Luis Potosí, México
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem solved

    Thank you very much Codeexploit, the problem was in the smtp code, now I can work in on that,

    regards,

    Eduardo Cazares

  8. #8
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    I have troubles with my code.
    If I copy yours, but wish to send it directly to an email adress, how would you adapt it ?

    //specify your SMTP server name here; for ex i've mentioned mail.yoursmtpserver.com replace it with yours
    ini_set("SMTP","mail.yoursmtpserver.com");

  9. #9
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Any ideas ?

Bookmarks

Posting Permissions

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