Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Ajax Functions
- function bberri_phpmailer( $phpmailer ) {
- $phpmailer->IsSMTP(); //switch to smtp
- $phpmailer->Host = 'smtp.gmail.com';
- $phpmailer->Port = 587;
- $phpmailer->Username = 'contacto@bberri.cl';
- $phpmailer->Password = 'Contacto_2017';
- }
- function acripal_send_contact_form() {
- $name = wp_strip_all_tags($_POST['name']);
- $email = wp_strip_all_tags($_POST['email']);
- $message = wp_strip_all_tags($_POST['message']);
- if($name && $email && $message){
- $to = 'mail@gabrielescobar.cl';
- $subject = 'Nuevo Mensaje - Formulario de Contacto '.get_bloginfo('name').' Website';
- $body = 'Nombre: '.$name."\n";
- $body .= 'E-mail: '.$email."\n";
- $body .= 'Mensaje: '.$message."\n";
- $body .= 'Enviado el '.date('d/m/Y G:i');
- $headers[] = 'From: '.get_bloginfo('name').' <'.$to.'>';
- $headers[] = 'Reply-To: '.$name.' <'.$email.'>';
- $headers[] = 'MIME-Version: 1.0';
- $headers[] = 'Content-Type: text/plain; charset='.get_bloginfo('charset');
- wp_mail($to, $subject, $body, $headers);
- echo 1;
- } else {
- echo 0;
- wp_send_json_error();
- }
- die();
- }
- add_action( 'phpmailer_init', 'bberri_phpmailer' );
- add_action('wp_ajax_nopriv_acripal_send_user_contact_form', 'acripal_send_contact_form');
- add_action('wp_ajax_acripal_send_user_contact_form', 'acripal_send_contact_form');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement