my old contact form
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

send.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?
  2. ini_set("display_errors", "off");
  3. ini_set("log_errors", "on");
  4. ini_set('error_log', $_SERVER['DOCUMENT_ROOT'].'/contact/log.log');
  5. set_include_path('/path/to/zend/');
  6. if(isset($_POST['email'])){
  7. $email = $_POST['email'];
  8. $name = $_POST['name'];
  9. $msg = $_POST['msg'];
  10. $from = $_POST['from'];
  11. include 'Zend/Validate/EmailAddress.php';
  12. $emailValidator = new Zend_Validate_EmailAddress();
  13. if(trim($email) == '' || trim($name) == '' || trim($msg) == ''){
  14. echo '<div class="error"><span class="english">You must fill every fields</span><br/><span class="french">Vous devez remplir tous les champs</span></div>';
  15. exit;
  16. }
  17. if($emailValidator->isValid($email) && trim($name) != '' && trim($msg) != ''){
  18. include 'Zend/Mail.php';
  19. $body = 'Message de '.$name.' ('.$email.")\n\n";
  20. $body .= $msg;
  21. $message = new Zend_Mail('utf-8');
  22. $message->setFrom($email, 'Contact')
  23. ->setSubject('Un message du site (ref : '.$from.')')
  24. ->setBodyText($body)
  25. ->setReplyTo($email, $name)
  26. ->addTo('mail@example.net');
  27. $message->send();
  28. echo 'ok';
  29. exit;
  30. }else{
  31. $errorType = $emailValidator->getErrors();
  32. if(isset($errorType[0])){
  33. $errormsg = $emailValidator->getMessageTemplates();
  34. echo '<div class="error"><span class="english">Email : '.str_replace('%value%', $email, $errormsg[$errorType[0]]).'</span></div>';
  35. exit;
  36. }
  37. }
  38. }