2

I have to use mail function in my project. When I host my project on hostgator, it doesn't work. But when I host on other server, it works fine. I can't understand problem. If anyone know answer then please explain or suggest me link from where I can understand from beginning. Thank You. Here is my code.

$to_address = "test@somedomain.com";
$subject = "This goes in the subject line of the email!";
$message = "This is the body of the email.\n\n";
$message .= "More body: probably a variable.\n";
$headers = "From: test@somedomain.com\r\n";
mail("$to_address", "$subject", "$message", "$headers");
Akshay Vaghasiya
  • 1,597
  • 9
  • 36
  • 60

1 Answers1

9

Supposing you are on hostgator.in & specially you mentioned hostgator, it does not allow mail sending if the domains are other than one on which you have hosted your site. Either sender or receiver's mail is should be same as of hosting e.g. if ypu have a site a.com then either sender's mail id or receiver's mail id should have @a.com

lakshman
  • 656
  • 4
  • 18