Salve a tutti, mi scuso anticipatamente per le mie domande da niubbo appena iscritto, purtroppo il PHP é un linguaggio che non conosco e ho bisogno urgentemente di aiuto in quanto ho una scadenza e non sono riuscito a risolvere usando dei codici trovati su internet, la mia più grande difficoltà sta nel fatto che non posso usare una form diversa da questa (altrimenti avrei risolto subito), ma posso solo modificare quella che ho già.
Questa form email fa parte di un sito Wordpress, mi servirebbe che questa oltre ad inviare una email al destinatario principale, invii anche una copia del messaggio a un altro indirizzo email di mia scelta tramite BCC (stealth), come posso fare?
Grazie anticipatamente!
Questo è il codice:
Codice PHP:
<?php
// CONFIGURATION --------------------------------------------------------------
// This is the email where the contact mails will be sent to.
// In WordPress Edition, it will be done via the theme admin. You don't need to modify this file under WP Edition.
$config['recipient'] = 'you@example.com';
// This is the subject line for contact emails.
// The variable %name% will be replaced with the name of the sender.
$config['subject'] = 'Contact message from %name%';
// These are the messages displayed in case of form errors.
$config['errors'] = array
(
'no_name' => 'Full name is empty',
'no_email' => 'Email address is empty',
'invalid_email' => 'Invalid email address',
'no_message' => 'Include your message',
);
// END OF CONFIGURATION -------------------------------------------------------
// Ignore non-POST requests
if ( ! $_POST)
exit('Nothing to see here. Please go back to the site.');
// Was this an AJAX request or not?
$ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
// Set the correct HTTP headers
header('Content-Type: text/'.($ajax ? 'plain' : 'html').'; charset=utf-8');
// Extract and trim contactform values
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$message = isset($_POST['message']) ? trim($_POST['message']) : '';
$config['recipient'] = isset($_POST['c_email']) ? trim($_POST['c_email']) : '';
// Take care of magic quotes if needed (you really should have them disabled)
if (get_magic_quotes_gpc())
{
$name = stripslashes($name);
$email = stripslashes($email);
$message = stripslashes($message);
}
// Initialize the errors array which will also be sent back as a JSON object
$errors = NULL;
// Validate name
if ($name == '' || strpos($name, "\r") || strpos($name, "\n"))
{
$errors['name'] = $config['errors']['no_name'];
}
// Validate email
if ($email == '')
{
$errors['email'] = $config['errors']['no_email'];
}
elseif ( ! preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', $email))
{
$errors['email'] = $config['errors']['invalid_email'];
}
// Validate message
if ($message == '')
{
$errors['message'] = $config['errors']['no_message'];
}
// Validation succeeded
if (empty($errors))
{
// Prepare subject line
$subject = str_replace('%name%', $name, $config['subject']);
// Additional mail headers
$headers = 'Content-Type: text/plain; charset=utf-8'."\r\n";
$headers .= 'From: '.$email;
// Send the mail
if ( ! mail($config['recipient'], $subject, $message, $headers))
{
$errors['server'] = 'There seems to be a technical problem with our server. We are sorry. '.
'Could you mail your message directly at '.$config['recipient'].'? Thank you.';
}
}
if ($ajax)
{
// Output the possible errors as a JSON object
echo json_encode($errors);
}
else
{
// Show a simple HTML feedback message in case of non-javascript support
if (empty($errors))
{
echo '<h4>Thank you</h4>';
echo '
Your message has been sent.</p>';
}
else
{
echo '<h4>Oops!</h4>';
echo '
Please go back and fix the following errors:</p>';
echo '<ul>[*]';
echo implode('[*]', $errors);
echo '[/list]';
}
}