I am new in namecheap domain server. I am trying to send a simple mail on that namecheap server. It wasn't sending mail and returned an empty value not any error.
Here is my sample code.
$to = "raamanmca@gmail.com";
$subject = "HTML email";
$message = "Hello this is testing mail";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <ramalingam@binaryswan.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
if(mail($to,$subject,$message,$headers))
{
echo "Mail sent...";
}
else
{
echo "Mail not sent";
}
Suppose i assign $to and $from mailID within a namecheap server mail's then mail sent successfully.
Example:
$to='test@binaryswan.com'
$from='hello@binaryswan.com'
But i am changing the mail $to OR $from into gmail server like test@gmail.com
then it will not send a mail and is also returning empty value without error. How to fix.
From (Not receiving email from the PHP mail() method) Only domains that are hosted on our servers can be used in 'From' field. Any domain that is not hosted with us cannot be added to 'From' field. We had to take this measure to prevent sending spam using forums, guest books and contact forms scripts. For your site scripts to work properly you should set 'From' field to email account that has been created in your cPanel.
It's related to my issue but i don't know how to "set 'From' field to email account in my cPanel."