Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function send_email ($to_email, $from_email, $from_name, $subject, $msg) {
- //split up to email array, if given
- if (is_array($to_email)) {
- $to_email_string = implode(', ', $to_email);
- }
- else {
- $to_email_string = $to_email;
- }
- //assemble headers
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= "From: $from_name <$from_email>" . "\r\n";
- //send via PHP's mail() function
- mail($to_email_string, $subject, $msg, $headers);
- }
- //USAGE
- /*
- send_email("me@gmail.com", "roger@att.com", "Roger", "Hello There", "<html>Hello There <strong>Bob</strong>! How are you doing</html>!");
- 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>!");
- */
- //PEDIDO DE VISITA
- if(isset($_POST['pedido_submit']) && $_POST['pedido_submit'] == "submitted"){
- //MESSAGE TO PEDIDO DE VISITA
- $from_email = $_POST['email'];
- $from_name = $_POST[''];
- $subject = "Pedido de Visita aos Centros Produtores EDP";
- $to_email = 'bmcouto@site.com';
- $msg = '';
- $msg .= 'enviado';
- send_email($to_email, $from_email, $from_name, $subject, $msg);
- header("Location: ../centros_produtores/pedido_visita.php?msg=sucesso");
- } elseif(!isset($_POST['pedido_submit']) && !$_POST['pedido_submit'] == "submitted") {
- header("Location: ../centros_produtores/pedido_visita.php?msg=erro");
- }
- //CONTACTO GERAL
- if(isset($_POST['contacto_submit']) && $_POST['contacto_submit'] == "submitted"){
- //MESSAGE TO PEDIDO DE VISITA
- $from_email = $_POST['email'];
- $from_name = $_POST[''];
- $subject = "Contacto EDP - Empreendimentos Energéticos";
- $to_email = 'bmcouto@site.com';
- $msg = '';
- $msg .= 'enviado';
- send_email($to_email, $from_email, $from_name, $subject, $msg);
- header("Location: ../contactos/index.php?msg=sucesso");
- } elseif(!isset($_POST['contacto_submit']) && !$_POST['contacto_submit'] == "submitted") {
- header("Location: ../contactos/index.php?msg=erro");
- }
- ?>
Add Comment
Please, Sign In to add comment