0

I have the following function to send a mail in my php application where it works fine when I tested in localhost using Test Mail Server Tool. But when I hosted my application on server (byethost.com) the successful message comes up but I never receive the mail. Hope somebody could help me.

function sendPaymentApprovalMailToPayee($to,$receiver,$payno,$amount)
    {
        $from       =   $_SESSION['accemail'];
        $subject    =   "Payment Approved #'".$payno."'";

        $message    =   "<p>Dear ".$receiver." ,</p>
    <p>We are sending this mail to confirm that the payment of ".$amount." (Pay No : #".$payno." ) has been approved and successfully transferred to your account.</p>
    <p>Thanks & Best Regards,<br> Online Payment System - Team.</p>";

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        //send email
        return mail($to, $subject, $message, "From:" . $from,$headers);
      }
Rasclatt
  • 12,498
  • 3
  • 25
  • 33
Dilukshan Mahendra
  • 3,230
  • 7
  • 41
  • 62
  • 1
    Please check the SMTP server configurations with your hosting service provider as this depends upon server. – Pupil Jul 27 '15 at 05:09
  • Well there are no stops if mail fails, so you will always get that success message. You need to first do something like: `if(mail($to, $subject, $message, "From:" . $from,$headers)) { echo 'success'; } else { echo 'fail'; }` – Rasclatt Jul 27 '15 at 05:09
  • 1
    After, revising your success/fail portion, do as @Pupil recommends because if it works in one spot and not the other, it may be a server setting that you may not have direct control over. – Rasclatt Jul 27 '15 at 05:12
  • By doing the above validation it echoed "Success"but still the mail wasn't received – Dilukshan Mahendra Jul 27 '15 at 05:25

1 Answers1

0

try to change

 mail($to, $subject, $message, "From:" . $from,$headers);

to

 mail($to, $subject, $message, "From:" . $from.$headers);