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 9 of 9
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts

    Contact form reply

    Okay, I'm looking at developing this code.

    The problem : The "from" in your inbox is your site, but to do a email auto respond there is not an email to reply to (unless you auto respond to your site), but the email is in the content.

    The solution : Get email in content and send to inbox from that person, rather from site.

    But how ?

    PHP Code:
    <?php
        $name 
    $_POST['name'];
        
    $email $_POST['email'];
        
    $message $_POST['message'];
        
    $from 'From: TangledDemo'
        
    $to 'contact@tangledindesign.com'
        
    $subject 'Hello';
        
    $human $_POST['human'];
                
        
    $body "From: $name\n E-Mail: $email\n Message:\n $message";
                    
    if (
    $_POST['submit']) {
        if (
    $name != '' && $email != '') {
            if (
    $human == '4') {                 
                if (
    mail ($to$subject$body$from)) { 
                echo 
    '<p>Your message has been sent!</p>';
            } else { 
                echo 
    '<p>Something went wrong, go back and try again!</p>'
            } 
        } else if (
    $_POST['submit'] && $human != '4') {
            echo 
    '<p>You answered the anti-spam question incorrectly!</p>';
        }
        } else {
            echo 
    '<p>You need to fill in all required fields!!</p>';
        }
    }
    ?>
    Last edited by CHEWX; 10-30-2012 at 12:08 AM.

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts
    I should think before I post.

    PHP Code:
        $from 'From:'.$_POST['email'].';'
    FIXED.
    Last edited by CHEWX; 10-29-2012 at 09:43 PM.

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Okay, I've hit a problem.

    The email address comes in the inbox as from. When you click reply, it responds to that email.

    However when you set up an auto reply it responds to your site because the from email address is layed out like:

    From: joe@joebloggs.com via optic.yourhost.com

    And then responds to the latter email address, this only on auto response, not manual reply.

    Any reason why ?
    Last edited by CHEWX; 10-29-2012 at 09:47 PM.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Add the Reply-To header on the email as well.
    You cannot actually send out email from someone else's account without knowing their username and password.

  • #5
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Hey ?

    They will email me from joe@joebloggs.com

    I want to reply to them automatically as the contact form goes to an email address that is for submissions. So it's a thank-you for your submission, generic response.

    I want to reply to their email address they submit, NOT the 'via optic.yourhost.com' bit that is happening at the moment.

  • #6
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts
    PHP Code:
        $headers 'From:'.$_POST['email'].'' "\r\n" .
        
    'Reply-To:'.$_POST['email'].'' "\r\n" .
        
    'X-Mailer: PHP/' phpversion(); 
    I added that. But it still sends a reply to blah@optic.yourhost.com

  • #7
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts
    DONE !

    PHP Code:
        $returnpath "-f" $_POST['email']; 
    PHP Code:
        if (mail ($to$subject$body$headers$returnpath)) { 
    It was the bloody additional parameter -f that strips the mail-by and replaces with your variable.

    Source: http://php.net/manual/en/function.mail.php

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    The sendmail didn't obey the from and reply-to headers? On the plus side you've got it sorted, so glad you got it worked out!

  • #9
    Regular Coder
    Join Date
    Dec 2010
    Posts
    134
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by Fou-Lu View Post
    The sendmail didn't obey the from and reply-to headers? On the plus side you've got it sorted, so glad you got it worked out!
    Still ignored the reply to header and sent to name@host. So stripping the mail-by fixed this and uses reply to header again.


  •  

    Posting Permissions

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