Guest User

Untitled

a guest
Jul 6th, 2018
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 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.  
  28. if(isset($_POST['pedido_submit'])){
  29. if($_POST['pedido_submit'] == "submitted") {
  30.  
  31. //MESSAGE TO PEDIDO DE VISITA
  32. $from_email = $_POST['email'];
  33. $from_name = $_POST[''];
  34. $subject = "Pedido de Visita aos Centros Produtores EDP";
  35. $to_email = 'bmcouto@site.com';
  36.  
  37. $msg = '';
  38. $msg .= '<table name="pedidoVisitaMail" cellspacing="0" cellpadding="0" border="0">';
  39. $msg .= '<tr><td><img src="" alt="" width="" height="" border="0"></td><td></td></tr>';
  40. $msg .= '</table>';
  41.  
  42. send_email($to_email, $from_email, $from_name, $subject, $msg);
  43.  
  44. header("Location: ../centros_produtores/pedido_visita.php?msg=sucesso");
  45.  
  46. } else {
  47.  
  48. header("Location: ../centros_produtores/pedido_visita.php?msg=erro");
  49.  
  50. }
  51.  
  52. } elseif(isset($_POST['contacto_submit'])) {
  53. if(isset($_POST['contacto_submit']) && $_POST['contacto_submit'] == "submitted"){
  54.  
  55. //MESSAGE TO CONTACTO GERAL
  56. $from_email = $_POST['email'];
  57. $from_name = $_POST[''];
  58. $subject = "Contacto EDP - Empreendimentos Energ&eacute;ticos";
  59. $to_email = 'bmcouto@site.com';
  60.  
  61. $msg = '';
  62. $msg .= 'enviado';
  63.  
  64. send_email($to_email, $from_email, $from_name, $subject, $msg);
  65.  
  66. header("Location: ../contactos/index.php?msg=sucesso");
  67.  
  68. } else {
  69.  
  70. header("Location: ../contactos/index.php?msg=erro");
  71.  
  72. }
  73.  
  74. } else {
  75.  
  76. //nenhum formulario submetido
  77.  
  78. }
  79.  
  80. ?>
Add Comment
Please, Sign In to add comment