Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contact_me.php
- <?php
- // check if fields passed are empty
- if(empty($_POST['name']) ||
- empty($_POST['phone']) ||
- empty($_POST['email']) ||
- empty($_POST['message']) ||
- !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
- {
- echo "No arguments Provided!";
- return false;
- }
- $name = $_POST['name'];
- $phone = $_POST['phone'];
- $email_address = $_POST['email'];
- $message = $_POST['message'];
- // create email body and send it
- $to = 'person@website.com'; // PUT YOUR EMAIL ADDRESS HERE
- $email_subject = "Website Contact Form: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
- $email_body = "You have received a new message from your website's contact form.nn"."Here are the details:nnName: $namennPhone: $phonennEmail: $email_addressnnMessage:n$message";
- $headers = "From: noreply@website.comn";
- $headers .= "Reply-To: $email_address";
- mail($to,$email_subject,$email_body,$headers);
- return true;
- ?>
- require_once('path/to/library/class.phpmailer.php');
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->Host = "smtp.postmarkapp.com";
- $mail->Port = 26;
- $mail->Username = "#@#@#@#@-####-@@@@-#####-@#@#@#@#@#@#";
- $mail->Password = "#@#@#@#@-####-@@@@-#####-@#@#@#@#@#@#";
- $mail->SetFrom('name@yourdomain.com', 'Web App');
- $mail->Subject = "A Transactional Email From Web App";
- $mail->MsgHTML($body);
- $mail->AddAddress($address, $name);
- if($mail->Send()) {
- echo "Message sent!";
- } else {
- echo "Mailer Error: " . $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement