SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Hawaii
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Contact Form Not Sending :(

    Cant seem to get an email through but I cant find any problems... Help much appreciated!

    Code:
    <?php
    if (isset($_POST['submit'])){
    
        //robot catch
        if(!empty($spam)){
            exit;
        }
    
        //create best new line command depending on OS
        if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
            $eol = "\r\n";
        } elseif (strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
            $eol = "\r";
        } else {
            $eol = "\n";
        }
    
        //set variables
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $subject = $_POST['subject'];
        $message = $_POST['message'];
    
        //email recipient
        $artsatheart = "Arts at Heart <email@gmail.com>, ";
    
        //set subject and message
        $subject = 'Arts at Heart - Email from '.$name.' regarding '.$subject;
        $msg =  'Name: ' .$name. $eol .'Email Address: ' .$email. $eol .'Phone Number: ' .$phone. $eol.'Message: ' .$message. $eol;
    
        //additional email information for servers
        $headers .= 'From: Arts at Heart <email@gmail.com>' . $eol;
        $headers .= 'Reply-To: ' . $name . ' <' .$email . '>' . $eol;
        $headers .= 'Return-Path: Arts at Heart <email@gmail.com>' . $eol;
        $headers .= "Message-ID:<" . date('M-d-y') . " support@" . $_SERVER['SERVER_NAME'] . ">" . $eol;
        $headers .= "X-Mailer: PHP v" . phpversion() . $eol;
    
        //mail email
        mail($artsatheart,$subject,$msg,$headers);
        header( 'Location: http://www.facebook.com/' ) ;
        exit();
    
    }else{
        header( 'Location: http://www.cnet.com/' ) ;
        exit();
    }
    ?>
    HTML Code:
    <div id="contactForm">
                <form method="post" action="submit.php">
                    <fieldset>
                        <div id="contactLeft">
                            <label for="name">Name</label>
                            <input id="contactInput" type="text" name="name" autofocus="autofocus" placeholder="Full Name" required="required">
    
                            <label for="email">E-mail</label>
                            <input id="contactInput" type="email" name="email" placeholder="name@domain.com" required="required">
    
                            <label for="phone">Phone</label>
                            <input id="contactInput" type="tel" name="phone" placeholder="ex. (555) 555-5555">
    
                            <label for="website">Subject</label>
                            <input id="contactInput" type="text" name="subject" placeholder="What's on your mind?" required="required">
                        </div>
    
                        <div id="contactRight">
                            <label for="message">Question/Comment</label>
                            <textarea id="message" name="message" placeholder="What's up?" required="required"></textarea>
    
                            <input id="" type="text" name="spam" placeholder="Spam Catcher">
    
                            <input id="submitButton" type="submit" name="submit"/>
                        </div>
                    </fieldset>
                </form>
            </div>

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,330
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Try changing this:

    Code:
    $artsatheart = "Arts at Heart <email@gmail.com>, ";
    to this:

    Code:
    $artsatheart = "email@gmail.com";
    I'm no PHP guy, but I think that should be a pure email address only.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $artsatheart "Arts at Heart <email@gmail.com>, "
    Try without the comma
    PHP Code:
     $artsatheart "Arts at Heart <email@gmail.com>"
    at http://php.net/manual/en/function.mail.php under "to" it says nothing about that comma except if there is another recipient.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,330
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Off Topic:

    Well spotted, Franz48. And you've reminded me to check the PHP manual before ever trying to answer a PHP question.

  5. #5
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Hawaii
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha apparently it was the server. The code is all good. Agh! and the commas work.


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
  •