EstudioJuridicoAlmagro_Web/www/wpv_common/assets/includes/sendmail.php
david f72df580c3 - Importación inicial
- Ticket 1166 -> Orden de los idiomas ES FR EN RU

git-svn-id: https://192.168.0.254/svn/Proyectos.EstudioJuridicoAlmagro_Web/trunk@2 c22fe52d-42d7-ba4f-95f7-33effcf65713
2013-02-27 15:39:05 +00:00

26 lines
916 B
PHP

<?php
// sends an email to $_POST['to'], nothing fancy
require_once( '../../../../../../wp-load.php' );
$sitename = get_bloginfo('name');
$siteurl = home_url();
$to = isset($_POST['to'])? trim($_POST['to']) : '';
$name = isset($_POST['name'])? trim($_POST['name']) : '';
$email = isset($_POST['email'])? trim($_POST['email']) : '';
$content = isset($_POST['content'])? trim($_POST['content']) : '';
$error = false;
$error = ($to === '' || $email === '' || $content === '' || $name === '') ||
(!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $email)) ||
(!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $to));
if($error == false){
$subject = "$sitename's message from $name";
$body = "Site: $sitename ($siteurl) \n\nName: $name \n\nEmail: $email \n\nMessage: $content";
$headers = "From: $name ($sitename) <$email>\r\nReply-To: $email\r\n";
wp_mail($to, $subject, $body, $headers);
}