Results 1 to 7 of 7

Thread: Code or mail function problem?

  1. #1
    Join Date
    Jul 2006
    Location
    LittlePenang.com
    Posts
    1,778
    Rep Power
    191

    Code or mail function problem?

    hi all coder here,

    I do a simple form for inquiry purpose, inquiry.htm and here is the code


    Code:
    <form method="post" action="inquiry.php">
    
    <?php
    $ip = getenv("REMOTE_ADDR");
    $httpref = getenv ("HTTP_REFERER");
    $httpagent = getenv ("HTTP_USER_AGENT");
    ?>
    
    <input type="hidden" name="ip" value="<?php echo $ip ?>" />
    <input type="hidden" name="httpref" value="<?php echo $httpref ?>" />
    <input type="hidden" name="httpagent" value="<?php echo $httpagent ?>" />
    
        
        <p>Your Name: <br>
        <input type="text" name="visitor" size="35"> (Require)<br>
        Your Email:<br>
        <input type="text" name="visitormail" size="35"> (Require)<br>
        Subject <br>
        <input type="text" name="visitorsubject" size="35"> (Require)<br>
    
        
        <p>
        
        Attention:<br>
        <select name="attn" size="1">
        <option value=" General Support ">General Inquiry</option>
        <option value=" Sales & Presales ">Sales n Pre-Sales</option>    
        <option value=" Technical Support ">Technical Support</option>
        <option value=" Payment & Billing ">Payment & Billing</option>
        </select> <br>
    
        Mail Message: <br>
        <textarea name="notes" rows="4" cols="40"></textarea> 
    
        <input type="submit" value="Send">
    and after my visitor fill up the form, it will link to inquiry.php

    PHP Code:
    <html>
    <head> 
    <title>Sendemail Script</title>
    </head>
    <body>


    <?php

    $ip 
    $_POST['ip']; 
    $httpref $_POST['httpref']; 
    $httpagent $_POST['httpagent']; 
    $visitor $_POST['visitor']; 
    $visitormail $_POST['visitormail'];
    $visitorsubject $_POST['visitorsubject'] ;
    $notes $_POST['notes'];
    $attn $_POST['attn'];


    if (
    eregi('http:'$notes)) {
    die (
    "Do NOT try that! ! ");
    }
    if(!
    $visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
    {
    echo 
    "<h2>Use Back - Enter valid e-mail</h2>\n"
    $badinput "<h2>Feedback was NOT submitted</h2>\n";
    echo 
    $badinput;
    die (
    "Go back! ! ");
    }

    if(empty(
    $visitor) || empty($visitormail) || empty($notes )) {
    echo 
    "<h2>Use Back - fill in all fields</h2>\n";
    die (
    "Use back! ! "); 
    }

    $todayis date("l, F j, Y, g:i a") ;

    $attn $attn 
    $subject $attn

    $notes stripcslashes($notes); 

    $message $todayis [EST] \n
    Attention: 
    $attn \n
    Subject : 
    $visitorsubject \n
    Message: 
    $notes \n 
    From: 
    $visitor ($visitormail)\n


    Additional Info : IP = 
    $ip \n
    Browser Info: 
    $httpagent \n
    Referral : 
    $httpref \n
    "
    ;

    $from "From: $visitormail\r\n";


    mail("me@myemail.com"$subject$message$from);

    ?>

    <p align="center">
    Date: <?php echo $todayis ?> 
    <br />
    Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
    <br />

    Attention: <?php echo $attn ?>
    <br /> 
    Message:<br /> 
    <?php $notesout str_replace("\r""<br/>"$notes); 
    echo 
    $notesout?> 
    <br />
    <?php echo $ip ?> 


    </body>
    </html>
    after settle, i do try it, but unable to receive my email, any one can help me point out where is my problem?
    I blog IT Engineer LIFE at iCalvyn.com

    DreamNetwork If you don't mind Pirated

  2. #2
    Join Date
    Jan 2007
    Location
    -
    Posts
    365
    Rep Power
    157
    Quote Originally Posted by calvynlee View Post
    and after my visitor fill up the form, it will link to inquiry.php

    $from = "From: $visitormail\r\n";
    Replace the above with:

    $from = "From: $visitormail\r\n\r\n";

  3. #3
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    144

    It's not your code

    That code should work just fine (I couldn't see the error, so I ran it here). The double line break should be added by the mail() function. Do you have access to your web and mail server logs? Maybe there's an error in there. That is a dummy email address you posted and not the actual one you used, is it? Just checking!

  4. #4
    Join Date
    Jan 2007
    Location
    -
    Posts
    365
    Rep Power
    157
    Seanie could be right that the problem could be with the email address. I guessed the dummy email address was used by calvynlee just to post here. Or perhaps the email address used during the form submisssion is being rejected by Hotmail or Yahoo or your own email domain due to it being a non-existing email or something and being caught by filters or sent to Junk / Bulk folder.

  5. #5
    Join Date
    Jul 2006
    Location
    LittlePenang.com
    Posts
    1,778
    Rep Power
    191
    i do upload the same code in different server, and another server(exabytes) work fine for me.

    I do check with the server which unable to run, they reply me as below

    Dear Customer,

    We have disabled sending any emails with the field 'FROM; containing email address on the domain that does not exist on the server.

    We have taken these measures due to mass SPAM sending through forums, guestbooks, contact forms scripts on our servers. Mail relaying is also prohibited. You need to change your script's settings.

    In order for your scripts to work as intended, you need to set the 'FROM' field to an email address that you have created under your account.
    does this server giving a normal service?
    I blog IT Engineer LIFE at iCalvyn.com

    DreamNetwork If you don't mind Pirated

  6. #6
    Join Date
    Jan 2007
    Location
    -
    Posts
    365
    Rep Power
    157
    Ask them how you are supposed to get a visitor's enquiry via a form and reply back to the visitor if the visitor cannot put their own email address in the form. The visitor will have an email address not on your server or a Hotmail or Yahoo etc adress which will be blocked.

    Your workaround could be to use an email address of your own domain as the From field and place the visitor's email address in the body of the message. This has to be done via the script after the form is submitted. Then you will have to manually use that address when replying to the visitor.

  7. #7
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    144

    Maybe draconian,

    but not totally unreasonable. Maybe you need to be setting the 'Return-path' or something instead. I'm no mail guru, but it seems to me that another workaround would be to receive mail From enquiryform@yourdomain.com and cc to the sender, or to include the sender's address in the message only.

    Good luck with that!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. mail function debug help
    By calvynlee in forum Website Programming
    Replies: 8
    Last Post: 06-06-2008, 11:15 AM
  2. php ob_start function
    By Redzuan9999 in forum Website Programming
    Replies: 2
    Last Post: 04-12-2007, 10:38 AM
  3. Replies: 0
    Last Post: 16-01-2006, 12:03 PM
  4. Problem login to yahoo mail ac.
    By sportstoto3368 in forum Website Design
    Replies: 1
    Last Post: 22-10-2004, 06:24 AM
  5. problem in code(VB script
    By babysakura in forum Website Programming
    Replies: 0
    Last Post: 30-12-2003, 09:09 AM

Posting Permissions

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

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112