0

I have to send mail via website. I am using mail() function for the same. The problem is mail is not being sent and i am not able to identity the issue. Please help me.

here is the code that i am using :

<?php

   $to="admin@domain.com";
   $headers="FROM:me@domain.com"."\r\n"."BCC:myboss@domain.com";
   $subject="Customer Details.";
   $message="Following are the details of the customer - NAME :".$name." CONTACT NO :".$no." ORGANIZATION & DESIGNATION: ".$od."" ;
   //echo $message;

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

Here the $variables are coming from a form. They re all good.

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • "Here the $variables are coming from a form. They re all good.". We've only got your word for it, no evidence. – ADyson Aug 31 '17 at 11:40
  • BTW do you mean mail is not being _sent_, or not being _received_? There is a difference. The success of the first of those two events does not guarantee the success of the second. And you aren't even checking whether `mail()` returns true or not, so how do you know if it succeeded? Are you checking your server's logs and config? Is the server even configured to send mail? You've left out so much information it's impossible to give any meaningful help. Also have you researched this online at all? People ask questions about `mail()` all day long, you might find some help already exists. – ADyson Aug 31 '17 at 11:41
  • Its like, even if I provide static values, the mail is not being sent. – rushi kulkarni Aug 31 '17 at 11:44
  • This is likely to be an issue with the host over your script. Where are you hosting this? – Tex0gen Aug 31 '17 at 11:45
  • I did try and search, but couldn't find solution. And I mean mail is not sent, I have access to the inbox of "to" part of the mail function, but there I don't receive any new mail. – rushi kulkarni Aug 31 '17 at 11:46
  • Its on a personal server @SteveNorth, – rushi kulkarni Aug 31 '17 at 11:47
  • Okay, is sendmail setup on the server do you know? See what returns from `var_dump(mail($to, $subject, $message, $header));` – Tex0gen Aug 31 '17 at 11:48
  • its giving me false – rushi kulkarni Aug 31 '17 at 11:51
  • Sendmail is not setup on the server. [See here for linux setup of sendmail](http://www.linuxnix.com/how-to-configure-and-install-sendmail-in-linux/) Assuming you are running a linux distro that is? – Tex0gen Aug 31 '17 at 11:53
  • I aint, i am using windows – rushi kulkarni Aug 31 '17 at 11:55
  • An alternative for you would be to include 'mailgun' in your project. [See Mailgun](https://www.mailgun.com/) – Tex0gen Aug 31 '17 at 11:55
  • Okay, [See this page](http://www.php.net/manual/en/mail.configuration.php) for what you need to change in your php.ini in order for sendmail to work as on windows, mail is sent via SMTP. – Tex0gen Aug 31 '17 at 11:57
  • _"And I mean mail is not sent, I have access to the inbox of "to" part of the mail function, but there I don't receive any new mail."_ So you completely missed it when I said that sending does not guarantee receiving. They are _not_ the same thing. A lot has to happen in between. The fact is wasn't _received_ does **not** prove that it wasn't _sent_. However the fact that you subsequently reported that `mail()` returns `false` _does_ suggest it was never sent. Steve's suggestions for checking the setup are a good idea. – ADyson Aug 31 '17 at 12:42

0 Answers0