Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. contact_me.php
  2.  
  3. <?php
  4. // check if fields passed are empty
  5. if(empty($_POST['name']) ||
  6. empty($_POST['phone']) ||
  7. empty($_POST['email']) ||
  8. empty($_POST['message']) ||
  9. !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
  10. {
  11. echo "No arguments Provided!";
  12. return false;
  13. }
  14.  
  15. $name = $_POST['name'];
  16. $phone = $_POST['phone'];
  17. $email_address = $_POST['email'];
  18. $message = $_POST['message'];
  19.  
  20. // create email body and send it
  21. $to = 'person@website.com'; // PUT YOUR EMAIL ADDRESS HERE
  22. $email_subject = "Website Contact Form: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
  23. $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";
  24. $headers = "From: noreply@website.comn";
  25. $headers .= "Reply-To: $email_address";
  26. mail($to,$email_subject,$email_body,$headers);
  27. return true;
  28. ?>
  29.  
  30. require_once('path/to/library/class.phpmailer.php');
  31. $mail = new PHPMailer();
  32. $mail->IsSMTP();
  33.  
  34. $mail->SMTPAuth = true;
  35. $mail->Host = "smtp.postmarkapp.com";
  36. $mail->Port = 26;
  37. $mail->Username = "#@#@#@#@-####-@@@@-#####-@#@#@#@#@#@#";
  38. $mail->Password = "#@#@#@#@-####-@@@@-#####-@#@#@#@#@#@#";
  39.  
  40. $mail->SetFrom('name@yourdomain.com', 'Web App');
  41. $mail->Subject = "A Transactional Email From Web App";
  42. $mail->MsgHTML($body);
  43. $mail->AddAddress($address, $name);
  44.  
  45. if($mail->Send()) {
  46. echo "Message sent!";
  47. } else {
  48. echo "Mailer Error: " . $mail->ErrorInfo;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement