-1

The following code snippet is not working.

I checked my php.ini file, but it looks fine.

It's not returning any errors.

I have heard something about using something called sendmail.

I am using a Mac.

What am I doing wrong?

<form action="" method="post">
    <button class="btn" type="submit" name="submit" value="submit">CLICK</button>
</form>
<?php
    if(isset($_POST['submit'])) {
        error_reporting(); 
        $to  = 'philipnagel511@gmail.com';
        $subject = 'subject';
        $message = 'text';
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
        $headers .= 'To: user <philipnagel511@gmail.com>' . "\r\n";
        $headers .= 'From: server <nipdeliveries@gmail.com>' . "\r\n";
        mail($to, $subject, $message, $headers);
    }
?>

1 Answers1

0

You need to have an email server that PHP is configured to use. Here is a guide for how to set this up. Postifix which is mentioned comes standard with Macs and can be also installed on Linux.

Community
  • 1
  • 1
AmsalK
  • 416
  • 5
  • 9