Guest User

Untitled

a guest
Jul 6th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2.  
  3. function send_email ($to_email, $from_email, $from_name, $subject, $msg) {
  4. //split up to email array, if given
  5. if (is_array($to_email)) {
  6. $to_email_string = implode(', ', $to_email);
  7. }
  8. else {
  9. $to_email_string = $to_email;
  10. }
  11.  
  12. //assemble headers
  13. $headers = 'MIME-Version: 1.0' . "\r\n";
  14. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  15. $headers .= "From: $from_name <$from_email>" . "\r\n";
  16.  
  17. //send via PHP's mail() function
  18. mail($to_email_string, $subject, $msg, $headers);
  19. }
  20.  
  21. //USAGE
  22. /*
  23. send_email("me@gmail.com", "roger@att.com", "Roger", "Hello There", "<html>Hello There <strong>Bob</strong>! How are you doing</html>!");
  24. send_email(array("me@gmail.com", "sal@gmail.com"), "roger@att.com", "Roger", "Hello There", "<html>Hello There <strong>Bob</strong>! How are you doing</html>!");
  25. */
  26.  
  27. //PEDIDO DE VISITA
  28. if(isset($_POST['pedido_submit']) && $_POST['pedido_submit'] == "submitted"){
  29.  
  30. //MESSAGE TO PEDIDO DE VISITA
  31. $from_email = $_POST['email'];
  32. $from_name = $_POST[''];
  33. $subject = "Pedido de Visita aos Centros Produtores EDP";
  34. $to_email = 'bmcouto@site.com';
  35.  
  36. $msg = '';
  37. $msg .= 'enviado';
  38.  
  39. send_email($to_email, $from_email, $from_name, $subject, $msg);
  40.  
  41. header("Location: ../centros_produtores/pedido_visita.php?msg=sucesso");
  42.  
  43. } elseif(!isset($_POST['pedido_submit']) && !$_POST['pedido_submit'] == "submitted") {
  44.  
  45. header("Location: ../centros_produtores/pedido_visita.php?msg=erro");
  46.  
  47. }
  48.  
  49.  
  50. //CONTACTO GERAL
  51. if(isset($_POST['contacto_submit']) && $_POST['contacto_submit'] == "submitted"){
  52.  
  53. //MESSAGE TO PEDIDO DE VISITA
  54. $from_email = $_POST['email'];
  55. $from_name = $_POST[''];
  56. $subject = "Contacto EDP - Empreendimentos Energ&eacute;ticos";
  57. $to_email = 'bmcouto@site.com';
  58.  
  59. $msg = '';
  60. $msg .= 'enviado';
  61.  
  62. send_email($to_email, $from_email, $from_name, $subject, $msg);
  63.  
  64. header("Location: ../contactos/index.php?msg=sucesso");
  65.  
  66. } elseif(!isset($_POST['contacto_submit']) && !$_POST['contacto_submit'] == "submitted") {
  67.  
  68. header("Location: ../contactos/index.php?msg=erro");
  69.  
  70. }
  71.  
  72. ?>
Add Comment
Please, Sign In to add comment