I can't get the mail() function to work. Do I have to make any changes in the cPanel. Do I have to configure anything?
I was using the code below:
mail('abc@xyz.com','Subject sdsas','Random Message','From: zzz@yyy.com');
I can't get the mail() function to work. Do I have to make any changes in the cPanel. Do I have to configure anything?
I was using the code below:
mail('abc@xyz.com','Subject sdsas','Random Message','From: zzz@yyy.com');
Note: The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP. As such, the to parameter should not be an address in the form of "Something ". The mail command may not parse this properly while talking with the MTA.
See: PHP: mail - Manual
How can I get PHP mail() to work? Need help configuring a MTA
MTA for receiving mails, in PHP
Both questions are dealing with MTA, it may be good to know if the hoster fulfills the requirements needed to send mails by using PHP.
You may use the following---
<?php
$to = "abc@xyz.com";
$subject = "My subject";
$msg= "Random Message";
$headers = "From: zzz@yyy.com";
mail($to,$subject,$msg,$headers);
?>
It will not work on the localhost. It will work only on the server.
It will help you.