Wednesday, November 26, 2014

PHP mail function not working on CentOS server with WHM, testing in browser.



I configured LAMP server in VPS server, I tried to run PHP mail function in web browser, but it was not working in the 1st attempt. Later, I solved the issue.

1. Login to WHM with username and password.


2. Go to Server Configuration => Tweake Setting.


3.  In side the Tweake Settings go to Mail option,  change the 'Prevent “nobody” from sending mail' to Off Default Mode.




4. Create the PHP mail function script in the Document root "test.php".

<?php
  $to = "Destination mail ID";
  $message = "Hello World";
  $subject = "User Activated";
  $headers = 'MIME-Version: 1.0' . "\r\n";
  $headers = 'Content-type: test/html; charset=iso-8859-1' . "\r\n";

  //Additional Header
  $headers = 'From: Easyship <info@easyshipping.com>' . "\r\n";
  
  //send email
  mail($to, $subject, $message, $header);
  
  //Email response
  dir ("Reach Here"); 
?>

5. Go to web browser and test the PHP mail function script in browser.
    URL:-    http://IP Address/~easy/easyshipping/test.php    or   DomainName/test.php
     

6. If there is no error, go to the mail box and check for php test mail.



That's it...






No comments:

Post a Comment