Hello i have problem in sending a mail in cpanel's webmail Account. I tried this code and it's working perfectly i tried it with gmail account and another cpanel's account. Example : I changed the $to field with abc@gmail.com & info@domainname2.com (Another Cpanel account) & both of them working perfectly.
And it's not working with same Domain Name. My code is in domainname1 and i'm sending mail to the same domain.
$to = "abc@gmail.com";
$subject = "foo";
$body = "foo";
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: Sender Name <sender@domain.com>";
$headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: Recipient Name <receiver@domain3.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
if(@mail($to, $subject, $body, implode("
", $headers)))
{
echo "Mail Sent Successfully";
}else{
echo "Mail Not Sent";
}