Is this code enough if user want to send email to my webmail? Or I need to make changes?
<?php
$mail = $_POST['mail'];
$name = $_POST['name'];
$subject = $_POST['subject'];
$text = $_POST['text'];
$to = "youremail@domain.com";
$message =" You received a mail from ".$name;
$message .=" Text of the message : ".$text;
if(mail($to, $subject,$message)){
echo "Your message was sent successfully.";
}
else{
echo "there's some errors to send the mail, verify your server options";
}
?>
I suggest adding a header to the email with encoding (UTF8), encode the subject line so you won’t get Gibberish (if you use other non-Latin characters for example) and handle basic events, success or not.