0

I cannot figure out my mistake. Hopefully you guys can help.

        $receiver = 'myemail@domain.tld';
        $msg = 'some text goes here';

        $msg = wordwrap($msg, 70);

        $subject =  'Email Test';

        $headers =  'From: email@domain.tld' . PHP_EOL . 
                    'Reply-To: email@domain.tld' . PHP_EOL . 
                    'MIME-Version: 1.0' . PHP_EOL . 
                    'Content-Type: text/html; charset=ISO-8859-1';

        echo ($receiver . ' ' . $subject . ' ' . $msg . ' ' . $headers);

        if(!mail($receiver, $subject, $msg, $headers)){

            error_reporting(0);

            echo ('<pre>' . date("Y-m-d H:i:s") . ': ');

            var_dump (error_get_last());
            echo ('<br />');
            print_r (error_get_last());

            echo ('</pre>');

        }else{ /* Redirect to another page */ }

So if i call submit.php i get the following message: 2015-02-24 10:06:50: NULL

I really don't undersand why. no log is filled with errors. I also tried error_reporting(E_ERROR | E_WARNING | E_PARSE); bit it stays null

lechnerio
  • 884
  • 1
  • 16
  • 44

1 Answers1

0

Take a look at this page for informations about error_get_last();

http://php.net/manual/en/function.error-get-last.php

Returns NULL if there hasn't been an error yet.

These 2 pages could also help you a lot i guess ;)

PHP mail function always returning false

http://www.mendoweb.be/blog/php-send-mail-smtp-server-authentication-required/

Community
  • 1
  • 1
Jesper
  • 3,816
  • 2
  • 16
  • 24
  • but if(!mail(..)) triggers, so there has to be something wrong with sending? – lechnerio Feb 24 '15 at 09:45
  • Yes, but doesn't have to be the variables you've declared. I recommend using PHPMailer, since it's pretty straight forward and easy to use, if you aren't against external libs. https://github.com/PHPMailer/PHPMailer else maybe take a look at these toubleshooting steps: http://stackoverflow.com/questions/1658043/troubleshooting-php-mail – Jesper Feb 24 '15 at 09:52