0

I have a form on my site I'm trying to send, it works locally only when i upload it to my server I don't receive a message, can anybody see or tell me why this may be?

I understand my form isn't the most secure but I'm not worried about that for now, I'm curious as to why the form doesn't send when it's on my server...

FWIW I'm also running an apache server.

<?php

if ( empty($_POST['req'])) {

    echo '<span style="color:#ff0000; font-weight:700; font-size:12px;">Please ensure all fields marked with an asterisk(*) have been completed.</span>';

} else {

    foreach ($_POST as $key => $value)
    $message = '';
    $message .= "Field ".htmlentities($key)." is ".htmlentities($value)."\r\n";

    if(mail('liam@site.co.uk', 'Information', $message)){ 

    echo '<span style="color:green; font-weight:700; font-size:12px;">Thankyou, we will be in touch within 24 hours.</span>';

    };
};

?>
Liam
  • 9,725
  • 39
  • 111
  • 209
  • 1
    I suspect mail on the local server isnt configured. Id recommend using a library like PHPMailer for sending email. It has many features and should work for your form =) https://github.com/Synchro/PHPMailer Apart form that it will be a matter of testing sendmail see this question: http://stackoverflow.com/questions/6590934/php-sendmail-works-in-ubuntu-command-line-but-not-from-a-php-file – azzy81 Nov 14 '13 at 16:40
  • Well there is first some error in your PHP code, brackets missing on "foreach" block. Then configure your PHP mail: http://php.net/manual/en/mail.configuration.php – Code-Source Nov 14 '13 at 16:47

0 Answers0