Posted By

ryarwood on 06/18/11


Tagged

form php mime contact FormMail


Versions (?)

Standard Contact Form


 / Published in: PHP
 

Just a standard mail function. Set the fields on the top, send it at the bottom.

  1. <?php
  2. # | $Id$
  3.  
  4. define('SITE_BASE', dirname(__FILE__));
  5. require_once SITE_BASE . '/mime.php';
  6.  
  7. $mail = array();
  8.  
  9. # | email headers
  10. # | NEED TO EDIT THIS SECTION
  11. $mail['sender'] = $_POST['eMail'];
  12. $mail['recipient'] = '[email protected]';
  13. $mail['subject'] = 'Interactive Marketing Tools';
  14. $mail['header'] = sprintf("From: %s\n", $mail['sender']);
  15. $mail['header'] .= sprintf("Reply-To: %s",$mail['sender']);
  16.  
  17. # | email field content
  18. # | AND EDIT THIS BELOW
  19. $mail['fields'][] = array('label' => 'First Name', 'variable' => $_POST['firstName']);
  20. $mail['fields'][] = array('label' => 'Last Name', 'variable' => $_POST['lastName']);
  21. $mail['fields'][] = array('label' => 'company', 'variable' => $_POST['company']);
  22. $mail['fields'][] = array('label' => 'address', 'variable' => $_POST['address']);
  23. $mail['fields'][] = array('label' => 'city', 'variable' => $_POST['city']);
  24. $mail['fields'][] = array('label' => 'state', 'variable' => $_POST['state']);
  25. $mail['fields'][] = array('label' => 'zip', 'variable' => $_POST['zip']);
  26. $mail['fields'][] = array('label' => 'phone', 'variable' => $_POST['phone']);
  27. $mail['fields'][] = array('label' => 'fax', 'variable' => $_POST['fax']);
  28. $mail['fields'][] = array('label' => 'eMail', 'variable' => $_POST['eMail']);
  29. $mail['fields'][] = array('label' => 'webURL', 'variable' => $_POST['webURL']);
  30. $mail['fields'][] = array('label' => 'howDid', 'variable' => $_POST['howDid']);
  31. $mail['fields'][] = array('label' => 'comments', 'variable' => $_POST['comments']);
  32.  
  33. # | message formatting
  34. # | NO NEED TO TOUCH BELOW HERE
  35. $mail['message'] = "_____________________________________\n";
  36.  
  37. foreach($mail['fields'] as $field) {
  38. $mail['message'] .= sprintf("%s: %s\n",$field['label'], stripslashes($field['variable']));
  39. }
  40.  
  41. $mail['message'] .= "_____________________________________\n";
  42.  
  43. # | mail dispatch
  44. mail( $mail['recipient'], $mail['subject'], $mail['message'], $mail['header']);
  45.  
  46. ?>

Report this snippet  

You need to login to post a comment.