-1

I am trying to send an email using php mail() function. Its returns true but not sending mail and showing following.

The description for Event ID 2 from source PHP-7.2.2 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

I am using Windows server

<?php
$to      = 'myemail@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: myemail1@gmail.com' . "\r\n" .
    'Reply-To: myemail@gmail.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

The script should send an email to myemail@gmail.com

  • Does PHP work at all? Try: ` – KIKO Software Sep 23 '19 at 05:18
  • Could you please post dump results? – Jaymin Sep 23 '19 at 05:31
  • @KIKOSoftware Yes PHP is working fine. I used my gmail ID as receiver side. – Dipak Kakade Sep 23 '19 at 06:16
  • @Jaymin Thank you for your reply. dump results following bool(true) – Dipak Kakade Sep 23 '19 at 06:17
  • The most likely problem, apart from the message you showed, is that GMail is blocking the email. – KIKO Software Sep 23 '19 at 06:24
  • @KIKOSoftware gmail not blocking. When I use SMTP its sending emails. The problem is with php mail() function. **I am using laragon 4.0.12** – Dipak Kakade Sep 23 '19 at 06:48
  • Are you trying to do this on Linux based server or Windows machine? Have you checked how the SMTP server is set up in your system? – R A Sep 23 '19 at 07:16
  • When you are pretending that you are sending the email `From: myemail1@gmail.com`, then it can very well make a difference, whether you do that using SMTP with proper authentication, or just using PHP `mail`. If you use SMTP credentials to authenticate with Google’s mail servers - then they think this mail is probably genuine. If you _don’t_ do that, then Google has no way of knowing if the actual “owner” of that mail address wanted to send this mail - of if it was just some spammer. – 04FS Sep 23 '19 at 07:18
  • You're probably using SMTP in the PHP code in your question. So saying "When I use SMTP" does not convey any information. You need to be more specific, or provide other prove why GMail is certainly not blocking your email. Better try, for instance, the mailbox of your ISP, or any other mailbox you own. – KIKO Software Sep 23 '19 at 07:19

1 Answers1

0

Check your SPAM section in email.

  • List item
  • Thank you for reply, but there is no email in span as well. after hitting php script its returning true but at server side in windows application logs showing the message I mentioned. **I am using laragon 4.0.12** – Dipak Kakade Sep 23 '19 at 06:47