I am new to namecheap domain server. I am trying to send simple mail to this namecheap server. He did not send mail and returned an empty value, and 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 assigned $ to and $ from the mailID in the mail of the namecheap mail server, after which the mail was sent successfully.
Example:
$to=' test@binaryswan.com ' $from=' hello@binaryswan.com '
But I change the $ mail to OR $ from the gmail server, for example test@gmail.com , then it will not send mail and will also return an empty value without errors. How to fix.
From ( Do not receive mail from the PHP mail () method ) Only areas hosted on our servers can be used in the From field. Any domain that is not hosted by us cannot be added to the From field. We had to take this measure to prevent spam from being sent via forums, guest books, and contact form scripts. For your site scripts to work correctly, you must set the From field to the email account created in your cPanel.
This is due to my problem, but I donโt know how to "set the From field to the email address in my cPanel".
source share