0

I am trying to write an emailing script that does not depend on external code. Here is my code:

<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

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

However whenever I run the script it does nothing. It returns no errors it simply does not email to my email. Am I doing something wrong or is it something else? PS I use php 5.2

HittmanA
  • 223
  • 1
  • 2
  • 11
  • There is a strong chance it could be blocked by your email provider. Consider checking your spam/clutter folder. It may be flagged and placed in there, or your provider may just block it entirely. (This is especially common if you are on a shared host server.) – Spencer D Mar 29 '16 at 02:31
  • operating system? I believe there is a known issue on windows systems. – Jon Mar 29 '16 at 02:32
  • @Jon I am on a Mac currently – HittmanA Mar 29 '16 at 02:33
  • @SpencerDoak I am using a shared server (000webhost.com). Is there a way to get around this? I would not be spamming of course. This is simply to create a Contact Us page. – HittmanA Mar 29 '16 at 02:34
  • 1
    @HittmanA, unfortunately, I do not know any ways to make PHP's built in mail function work if your web server is already "*blacklisted*", so to speak, by email providers. You may need to go through a vetted SMTP service that can send the mail on your website's behalf. In which case, you may be able to still use the `mail()` function, and you will just need to modify your INI settings to reflect the SMTP server that you are mailing through. See [this StackOverflow question](http://stackoverflow.com/questions/14456673/sending-email-with-php-from-an-smtp-server) for more on that. – Spencer D Mar 29 '16 at 02:41

0 Answers0