1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Email form mail arrives from nobody....

Discussion in 'PHP' started by ian_ok, Feb 18, 2005.

  1. #1
    On my email form the mail arrives but from

    Using Apache server running PHP Version 4.3.10.

    I've changed the .htaccess file to show:

    php_value sendmail_from

    My send mail PHP fileis like this, have taken out most of the error correction etc..

    
    ini_set ("sendmail_from", "mail@domain.com");
    $email = 'mail@domain.com'; // CHANGED TO AVOID SPAM
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $from = $_POST['from']; //persons email address
    $name = $_POST['name'];
    $from_check = $_POST['from_check'];
    $tel = $_POST['tel'];
    
      $message = "Additional Requests:   ".$message;
      $message .= "\nName:   ".$name;
      $message .= "\nTel:   ".$tel;
      $message .= "\nEmail address 2 (could be different):   ".$from_check;
    
    (mail($email, $subject, $from, $message))
    
    PHP:
    Still mail arrive from nobody.....

    Thanks for anyhelp.

    Ian
     
    ian_ok, Feb 18, 2005 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    as it is, your mail command will always send the email to 'mail@domain.com'. if the $from variable is not set, the email that is sent to you will have a "nobody", "unknown", etc. as the sender of the email... which seems to be the case you're experiencing.

    are you sure your visitors are filling in the "from" field? do you validate to ensure that that field is not empty?
     
    daboss, Feb 18, 2005 IP
  3. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Daboss,

    The $from is validated and is only used in the context of who the message is send from is $from a reserved word/command?

    The problem is when I do testing, so not a user problem...as the page is not given to anyone.

    Even when I put (of course the real email address) in the from box, mail still arrives from nobody...I don't want it to show it has come from the person who sent it, but I want it to show that my email address has sent it and it not to show as

    **Could you edit your reply to show to prevent SPAM....Thanks...**

    Cheers Ian
     
    ian_ok, Feb 18, 2005 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This is how I got the From to work.

    $EMAIL equals your $from.

    
        $mailtext = 'whatever';
        $mailto = 'enquiries@oursite.co.uk';
    
        $mailsubject = 'Us - Contact us enquiry';
    
        $mailheaders = "From: $NAME Enquiry <$EMAIL>\r\n";
        $mailheaders .= "Reply-To: $EMAIL\r\n";
        $mailheaders .= "Return-Path: $EMAIL\n";
    
        if ($errormessage == '')
        {
           mail($mailto,$mailsubject,$mailtext,$mailheaders);
           header('Location: /thanks.shtml');
           exit;
        }
    PHP:
     
    T0PS3O, Feb 18, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you have access to the SMTP server logs, take look at what values the PHP client used and what the server replied. If you can get a detailed log (i.e. with MAIL FROM:, RCPT TO:, etc), this will show you what's going on.

    J.D.
     
    J.D., Feb 18, 2005 IP
  6. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Have got it to work by this:

    $headers = "From: ". $_POST['from'] ."\r\n";
    $headers .= "Reply-To: ". $_POST['from'] ."\r\n";

    Thanks for all your help...BUT I still can't get the rerturn-path to cahnge from

    Still that's not the end of the world...so am a happy bunny...thanks to DP

    Ian
     
    ian_ok, Feb 18, 2005 IP
  7. blacklab

    blacklab Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi Ian ok,

    I'm a relative newbee to php and the mail() function. For several months I have been using a simple confirmation script in php from an html form. The email has been sending great for ages but now I find that certain email addresses are not getting any confirmation email (registration details). I can test it by sending a test registration to myself - this again works fine. However, if I use another of my (private) email accounts, the email never arrives.

    Here's an extract of my code:-

    if ($action == "SEND") {

    ini_set ("sendmail_from", "mail@domain.com"); // changed for spam reasons!

    $from = "mail@2domain.com"; // changed
    $returnpath = "my email address"; // changed
    $replyto = "my email address"; // changed
    $name = "My domain";
    //$name = $_POST['name'];
    $mailheader = "From: $name <$mailto>\r\nReturn-path: $returnpath\r\nReply-to: $replyto\r\n";
    $mailto = $_POST['mailto']; // mailto is the email field in the html form
    $subject = "Mail Test";
    //$subject = $_POST['subject'];
    $message = "Hello World!";
    //$message = $_POST['message'];

    mail($mailto,$subject,$message,$mailheader);


    This sends to any email account (catch-all) on any of my hosted domains. I am sending from one of these domains.

    The Return-path always shows as nobody@server2 etc......


    Any thoughts? I seem to have tried everything that I have seen in forums but with no joy!

    Cheers, :) :confused:

    Blacklab
     
    blacklab, Sep 24, 2005 IP
  8. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The return I couldn't ever get to change, guess it's a server issue. Can not just set up a auto reply on the email address.

    Ian
     
    ian_ok, Sep 27, 2005 IP
  9. jiminoc

    jiminoc Peon

    Messages:
    37
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    so you got it all working now?
     
    jiminoc, Sep 27, 2005 IP