0

I've made a website with a mailing form, and the php to send it is as follows:

<?php
$to = "example@outlook.com";
$subject = $_POST["subject"];
$message = $_POST["message"];

$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

It won't send anything. Can anyone tell what's wrong in the script?

If it helps on anything, I'm trying to send to an Outlook email.

Thanks

  • 1
    Possible duplicate of [PHP mail form doesn't complete sending e-mail](http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – j08691 Apr 23 '16 at 15:33
  • 1
    Try to var_dump the status of the mail function. `var_dump(mail($to, $subject, $message, $headers))`and tell me what you get. – Hyder B. Apr 23 '16 at 15:34
  • are you sure your host allows you to send emails? – fonfonx Apr 23 '16 at 15:35
  • 3 questions: 1) Have you checked your spam folder?; 2) What is the result of the mail function?; 3) If it's FALSE, can you call error_get_last() after the mail() function and post the output of the error occurred? – Snake Apr 23 '16 at 15:37
  • Check your spam folder. If it is not there, are you sending mail from your local server or a professional hosting provider? – Hyder B. Apr 23 '16 at 15:38
  • 1)Nothing in the span folder – Bruno Durão Apr 23 '16 at 15:47
  • 2)3)Returns true, and no errors whatsoever – Bruno Durão Apr 23 '16 at 15:48
  • Have you configured and connected a mail server? – Arijoon Apr 23 '16 at 15:52
  • It's a free hosting service but it allows me to register an email, it's a subdomain tho: website.eu.pn. – Bruno Durão Apr 23 '16 at 15:53
  • nope...gonna do that now and post the results – Bruno Durão Apr 23 '16 at 15:54
  • Even if your host gave you email you still have to configure it as the mail servers are different. My first suggestion is to avoid php if you're new to web development. My second suggestion is to look up connecting and configuring mail server with php if you insist on using this languge – Arijoon Apr 23 '16 at 16:05

0 Answers0