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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Location
    Pretoria, South Africa
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML to PHP, not getting mail

    Hi

    I have a lacking knowledge of coding, I just don't know what I am doing wrong, here is the html snippet and php code;

    Code:
    <form method="post" action="Mailer.php" id="ContactForm">	
                                            <div class="success"> Contact form submitted!&nbsp;We will be in touch soon.</div>	
           								 		<fieldset class="left">	
                                                            <div class="block">
                                                            <label class="name">
                                                                <span class="bg"><input name="name" type="text" value="Name:" class="input"></span>
                                                                <span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label>
            											     <label class="email">
                											    <span class="bg"><input name="email" type="email" value="E-mail:" class="input"></span>
                											    <span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span></label>   
                                                             </div>
                                                             <div class="block">
                                                             <label class="message">
                											    <span class="bg"><textarea name="message" rows="1" cols="2">Message:</textarea></span>
                											    <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label>
            										         </div>
                                                             <div class="formButtons">
                                                                <div class="moreHolder">
                                                                    <a href="#" data-type="reset"></a>
                                                                    
                                                                </div>
                                                                <div class="moreHolder">
                                                                    <a href="#" name="submit" data-type="submit">send message</a>
                                                                    <span></span>
                                                                </div>
                                                             </div> 
        								  		    </fieldset>
                                                </form>
    PHP Code:
    <?php
        $name 
    $_POST['name'];
        
    $email $_POST['email'];
        
    $message $_POST['message'];
        
    $from 'From: Blah'
        
    $to 'blah@blah.co.za'
        
    $subject 'Message from Website';
                    
        
    $body "From: $name\n E-Mail: $email\n Message:\n $message";
                    
        if (
    $_POST['submit']) {                 
            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>'
              } 
        }
    ?>
    any help or suggestions would be greatly appreciated - TIA

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Does it indicate that the mail was successful by showing the message has been sent? Although you should be using isset() checks to ensure that the name, email and message are provided (NEVER make use of the $_POST['submit']), the PHP is otherwise fine.
    Since you don't have a submit button, I would presume it's your JS butchering it. If you add a submit button and remove the $_POST['submit'] check, I would presume it would work.
    If it indicates that the mail() is successful and still not received, that is not a PHP issue. That would be an issue with either the smtp not sending the mail, so you'd need to check the configured smtp error logs, or the receiver rejecting it. If it throws the false, that would indicate an issue with the smtp not accepting it for queue. I don't see an issue with the data you have here.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Sep 2013
    Location
    Pretoria, South Africa
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Fou-Lu

    I have removed the post submit from the php file, if all the fields are correct it does send the html code stating;

    Code:
    Contact form submitted!&nbsp;We will be in touch soon
    I don't see the php code stating;

    Code:
    Your message has been sent!
    I can't find anything on the server logs showing any issues with the mail not being sent, will remove the submit link and make the button this evening, and let you know what cuts. Thanks for your help so far really appreciate it!


  •  

    Posting Permissions

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