Estoy Tratando de implementar un formulario de contacto de propia creación (Sin plugins)en un template de wordpress contacto.php la que asocio a una nueva pagina de wordpress(como template de esta) y se me presento el problema de que no me funciona la Funcion de wordpress WP_MAIL probe un ejemplo (dice enviado)pero no me llegan los emails a mi correo asi que trate de implementarlo con PhpMailer segun se ve en el codigo que envio adjujunto más abajo
Código PHP :
<?php /* Template Name: Contactenos */ if($_POST[sent]){ $error = ""; if(!trim($_POST[your_name])){ $error .= "<p>Please enter your name</p>"; } if(!filter_var(trim($_POST[your_email]),FILTER_VALIDATE_EMAIL)){ $error .= "<p>Please enter a valid email address</p>"; } if(!trim($_POST[your_message])){ $error .= "<p>Please enter a message</p>"; } if(!trim($_POST[your_subject])){ $error .= "<p>Please enter a message</p>"; } if(!$error){ require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer(); $phpmailer->SMTPAuth = true; $phpmailer->Username = '[email protected]'; $phpmailer->Password = 'xxxxxxxo'; $phpmailer->IsSMTP(); // telling the class to use SMTP $phpmailer->Host = "mail.traiguencity.cl"; // SMTP server $phpmailer->From = $_POST[your_email]; $phpmailer->FromName = $_POST[your_name]; $phpmailer->Subject = $_POST[your_subject]; $phpmailer->Body = stripslashes($_POST[your_message]); //HTML Body $phpmailer->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $phpmailer->WordWrap = 50; // set word wrap $phpmailer->MsgHTML($_POST[your_message]); $phpmailer->AddAddress('[email protected]'); //$phpmailer->AddAttachment("images/phpmailer.gif"); // attachment if(!$phpmailer->Send()) { echo "Mailer Error: " . $phpmailer->ErrorInfo; } else { echo "Message sent!"; } } } ?> <?php get_header(); ?> <section id="primary"> <div id="content" role="main"> <div id="archives"> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h1><?php the_title(); ?></h1> <div> <?php if($email){ ?> <p><strong>Message succesfully sent. I'll reply as soon as I can</strong></p> <?php } else { if($error) { ?> <p><strong>Your messange hasn't been sent</strong><p> <?php echo $error; ?> <?php } else { the_content(); } ?> <form action="<?php the_permalink(); ?>" id="contact_me" method="post"> <input type="hidden" name="sent" id="sent" value="1" /> <div id="form"> <div id="lebel">Nombre (*)</div> <div id="input-field"><input type="text" name="your_name" id="your_name" value="<?php echo $_POST[your_name];?>" /></div> <div id="lebel">Email (*)</div> <div id="input-field"><input type="text" name="your_email" id="your_email" value="<?php echo $_POST[your_email];?>" /></div> <div id="lebel">Asuntot</div> <div id="input-field"><input type="text" name="your_subject" id="your_subject" value="<?php echo $_POST[your_subject];?>" /></div> <div id="lebel">Mensaje(*)</div> <div id="input-field"><textarea name="your_message" id="your_message"><?php echo stripslashes($_POST[your_message]); ?></textarea></div> <div id="lebel"> </div> <div id="input-field"><input type="submit" name = "send" value = "Contact Us" /></div> </div> </form> <?php } ?> </div><!-- .entry-content --> </div><!-- #post-## --> <?php endwhile; ?> </div> </div><!-- #content --> </section><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
Estare muy agradecido si me pudieran ayudar, y tambien decir si se puede implementar la funcion phpmailer() en un template