PHP Mail () function
function is used to send e-mail from a script.
Grammar:
Mail (to,subject,message,headers,parameters)
Parameters |
Description |
To |
Necessary. Specify email recipients. |
Subject |
Necessary. Specify the subject of email. Note: This parameter cannot contain any new line characters. |
Message |
Necessary. Defines the message to be sent. You should use LF (\ n) to separate the rows. Each line should be limited to 70 characters characters. |
Headers |
Optional. Specify additional headings, such as from, Cc, and BCC. You should use CRLF (\ r \ n) to separate additional headings. |
Parameters |
Optional. Specify additional parameters for the mail sender. |
Instance:
"Utf-8"><title> learning tutorial </title>phpfunction Spamcheck ($field) {//Filter_var () filter e-mail//Use the Filter_sanitize_email filter to remove illegal characters from a string in an e-mail message$field =Filter_var ($field, Filter_sanitize_email); //Filter_var () filter e-mail//verifying the value of an e-mail address using the Filter_validate_email filter if(Filter_var ($field, Filter_validate_email)) {returnTRUE; } Else { returnFALSE; }}if(Isset ($_request['Email'])){ //send a message if you receive a mailbox parameter//determine if a mailbox is legitimate$mailcheck = Spamcheck ($_request['Email']); if($mailcheck = =FALSE) {echo"Illegal input"; } Else { //Send mail$email = $_request['Email'] ; $subject= $_request['subject'] ; $message= $_request['message'] ; Mail ("[email protected]","Subject: $subject", $message,"From : $email" ); Echo"Thank you to using our mail form"; }}Else{ //Display the form if no mailbox parameters are presentEcho"<form method= ' post ' action= ' mailform.php ' >Email: <input name='Email'Type='text'><br>Subject:<input name='subject'Type='text'><br>Message:<br> <textarea name='message'Rows=' the'cols=' +'> </textarea><br> <input type='Submit'> </form>";}?></body>PHP Send e-mail