Hi guys, I am new in this world. i want to send email by php, Because I use the school environment, I cannot configure the server. I try to use mail() function, but it is not work, I checked the information that needs to configure php.ini, but could not find this file.
@NogDogApr 25.2018 — #Unfortunately, the built-in mail() function gives developers very little to work with as far as debugging goes, as it only returns either true or false with no warnings/errors, and even true does not guarantee that the server's mail program actually sent it.
As mentioned above, you may have to add a "From:" header to your $headers string. If so, it will probably have to be an email address that is configured for that server's mail set-up, so you may need to check with the system administrator to find out which address to use. Note that you can also set a "Reply-To:" header if you want the recipients to reply to a different address.
Personally, I almost always end up using [PHPMailer](https://github.com/PHPMailer/PHPMailer) when I have to do emails, as it provides many more options and better debugging. Your mileage may vary.
@rootApr 26.2018 — #Also, most web hosts require you to have the email address set up in the email server that you specify in the "from" / "Reply-To" parts of the email header.
You need to consult your web host for any limits that may be imposed by them.
if(isset($_POST['email'])) { $email_to = "***.******@*********.***"; $email_subject = "Summarized propose of the email"; //Errors to show if there is a problem in form fields.
function died($error) { echo "We are sorry that we can procceed your request due to error(s)"; echo "Below is the error(s) list <br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry to proceed your request due to error within form entries');