To send e-mails directly from a PHP script, you can use the mail() function.
- Syntax:mail(to, subject, body, headers);- to - a string with the address(es) of the receiver(s). Can be in either of the following formats:
<?php $to = 'your_email@domain.com'; // receiver address // Check for form submission if (isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message'])) { // get form data $from = 'From: '. $_POST['email']; $subject = $_POST['subject']; $body = $_POST['message']; $body = wordwrap($body, 70); // makes the body no longer than 70 characters long // send the email if (mail($to, $subject, $body, $from)) echo 'Thank you for using our mail form'; else echo 'Error, the message can not be sent'; } ?> <form action="" method="post"> E-mail: <input type="text" name="email" /><br /> Subject: <input type="text" name="subject" /><br /> Message:<br /> <textarea name="message" rows="8" cols="30"></textarea><br /> <input type="submit" value="Send" /> </form>- First, this script checks if the "email", "subject" and "message" fields are filled out. Gets data from these fields and use the mail() function to send the email, and returns a message for success or error.
<?php $to = 'your_email@domain.com'; // receiver address $erors = array(); // set an empty array that will contains the errors $regexp_mail = '/^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4})$/'; // an e-mail address pattern // Check for form submission if (isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message'])) { // remove tags and whitespace from the beginning and end of form data $_POST = array_map("strip_tags", $_POST); $_POST = array_map("trim", $_POST); // chech if all form fields are filled in correctly // (email address and the minimum number of characters in "subject" and "message") if (!preg_match($regexp_mail, $_POST['email'])) $erors[] = 'Invalid e-mail address'; if (strlen($_POST['subject'])<3) $erors[] = 'Subject must contain minimum 3 characters'; if (strlen($_POST['message'])<5) $erors[] = 'Subject must contain minimum 5 characters'; // if no errors ($error array empty) if(count($erors)<1) { // get form data $from = 'From: '. $_POST['email']; $subject = $_POST['subject']; $body = $_POST['message']; $body = wordwrap($body, 70); // makes the body no longer than 70 characters long // set headers (From, Encoding utf-8 and Reply-to) $headers = $from. "\r\n"; $headers .= 'Content-Type: text/plain; charset=utf-8'; $headers .= "Reply-To: ". $_POST['email']; // send the email if (mail($to, $subject, $body, $headers)) echo 'Thank you for using our mail form'; else echo 'Error, the message can not be sent'; } else { // else, if errors, it adds them in string format and print it echo implode('<br />', $erors); } } ?> <form action="" method="post"> E-mail: <input type="text" name="email" /><br /> Subject: <input type="text" name="subject" /><br /> Message:<br /> <textarea name="message" rows="8" cols="30"></textarea><br /> <input type="submit" value="Send" /> </form>
<table><tr> <th>Title 1</th> <th>Title 2</th> </tr></table>
.some_class { line-height: 150%; }
document.getElementById("id_button").onclick = function(){ window.open("http://coursesweb.net/"); }
$ar_dir = scandir("dir_name"); var_export($ar_dir);