-4

Im trying to learn how to send mail with PHP. I have the following that redirects (so my code is being read) but the mail isnt being sent, can anybody see any obvious syntax mistakes? I cant understand whats wrong?

    $aaa = $_POST['recipient-name'];
                    $bbb = $_POST['address-line'];
                    $ccc = $_POST['town-name'];
                    $ddd = $_POST['county-name'];
                    $eee = $_POST['postcode-name'];
                    $fff = $_POST['mesage-blob']; 


                    // The message
                    $message = $aaa . ' and ' . $bbb . ' and ' . $ccc . ' and ' . $ddd . ' and ' . $eee . ' and ' . $fff;

                    // In case any of our lines are larger than 70 characters, we should use wordwrap()
                    $message = wordwrap($message, 70, "\r\n");

                    // Send

                    mail('hello@site.co.uk', 'subjeeect', $message);  
                    header('Location: /thankyou.php');
taxicala
  • 21,408
  • 7
  • 37
  • 66
Liam
  • 9,725
  • 39
  • 111
  • 209
  • There is no syntax mistake. What does your mail.log says? – Richard May 19 '15 at 20:13
  • No syntax mistakes. Check your spam folder. Your e-mail is most likely being sent to the spam folder since the server you are sending from doesn't have any rep or history with the major e-mail providers. – Lloyd Banks May 19 '15 at 20:16

1 Answers1

0

The code seems to be ok, but I have only one question. Are you testing that code in a localhost? maybe xampp or wamp? If yes, this will never work as you cannot send an email with php's mail function unless you have a mail server in your localhost.

taxicala
  • 21,408
  • 7
  • 37
  • 66