/** * Send contact email to UR Imprint. */ function send_contact_email() { $name = $_POST['name']; $email = $_POST['email']; $to_email = get_contact_email(); $msg = $_POST['message']; $to = $to_email; $subject = $name . ' sent you a message - UR Imprint '; $headers = 'From: My Name <' . $to_email . '>' . "\r\n"; $message = '<html><body>'; $message .= '<h3>Contact</h3>'; $message .= '<p>Name: ' . $name . '</p>'; $message .= '<p>Email: ' . $email . '</p>'; if ($msg != '') { $message .= '<p>Message: ' . $msg . '</p>'; } $message .= '</body></html>'; add_filter('wp_mail_content_type', create_function('', 'return "text/html"; ')); $mail = wp_mail($to, $subject, $message, $headers); if (!$mail) { $message = array('error' => 1, 'message' => 'An error has ocurred. Please try again later.'); echo json_encode($message, JSON_FORCE_OBJECT); exit; } $message = array('error' => 0, 'message' => 'Thanks for your message ' . $name . '! <br /> We will get back to you shortly.'); echo json_encode($message, JSON_FORCE_OBJECT); exit; }
<textarea class="[ gui-textarea ][ required ]" name="message" id="" cols="30" rows="10" placeholder="your message..."></textarea> </fieldset> <fieldset class="[ margin-bottom ]"> <input type="hidden" name="action" value="send_contact_email"> <button class="[ button button--secondary ]" type="submit">Send</button> </fieldset> </form> <div class="[ column xmall-12 large-6 ][ color-light ]"> <p class="[ italic text-shadow ]">You can read our FAQs <a href="<?php echo get_post_type_archive_link('faq'); ?> ">here</a> and send us an email at <a href="mailto:<?php echo get_contact_email(); ?> "><?php echo get_contact_email(); ?> </a> or give us a call at <a href="tel:<?php echo get_contact_phone(); ?> "><?php echo get_contact_phone(); ?> </a></p> </div> </div> </div><!-- row --> </div><!-- wrapper --> </div> </section><!-- hero-contact -->
/** * Send contact email to PMI. */ function send_email_contacto() { $name = $_POST['name']; $email = $_POST['email']; $to_email = get_contact_email(); $msg = $_POST['message']; $to = $to_email; $subject = $name . ' te ha contactado a través de www.pmi.com.mx: '; $headers = 'From: My Name <' . $to_email . '>' . "\r\n"; $message = '<html><body>'; $message .= '<h3>Datos de contacto</h3>'; $message .= '<p>Nombre: ' . $name . '</p>'; $message .= '<p>Email: ' . $email . '</p>'; if ($msg != '') { $message .= '<p>Mensaje: ' . $msg . '</p>'; } $message .= '</body></html>'; add_filter('wp_mail_content_type', create_function('', 'return "text/html"; ')); $mail = wp_mail($to, $subject, $message, $headers); if (!$mail) { $message = array('error' => 1, 'message' => 'No se pudo enviar el correo.'); echo json_encode($message, JSON_FORCE_OBJECT); exit; } $message = array('error' => 0, 'message' => 'Gracias por tu mensaje ' . $name . '. En breve nos pondremos en contacto contigo.'); echo json_encode($message, JSON_FORCE_OBJECT); exit; }