Ciao ragazzi ho scritto questo codice affinchè un utente possa inserire delle informazioni che successivamente , al seguito del tasto invio , verrano reinderizzate sulla mia mail. Il programma gira correttamente su localhost e ricevo la mail con tutte le informazioni immesse nel form ma quando faccio l upload sul mio sito non va . Stesse impostazioni nessun cambio di riga di codice . Allego il tutto , sperando di ricevere una vostra risposta .
Grazie anticipatamente
contacts.php
<?php
$nl='<br>';
session_start();
require_once 'mailer/PHPMailerAutoload.php';
$errors = [];
if (isset($_POST['name'],$_POST['email'],$_POST['message'])) {
$fields = [
'name' => $_POST['name'],
'email' => $_POST['email'],
'message' => $_POST['message'],
];
foreach ($fields as $field => $data) {
if (empty($data)) {
$errors[] = 'The' . $fields . 'field is requried';
}
}
if (empty($errors)) {
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'ACCOUNT MIA MAIL'; // SMTP username
$mail->Password = 'PASSWORD DELLA MIA MAIL'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;
$mail->isHTML(true);
$mail->Subject = 'Nuovo Messaggio Arrivato da : nome sito';
$mail->Body = 'Nome : ' . $fields['name'] .$nl. ' (' . $fields['email'] . ') <p>' . $fields['message'] . '</p> ';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->FromName = 'NOME SITO';
$mail->AddAddress('MAIL PERSONALE ', 'NOME E COGONOME ');
if(!$mail->send()) {
die();
}
}
}else {
$errors[] = 'Soemthing went wrong';
}
$_SESSION['errors'] = $errors;
$_SESSION['fields'] = $fields;
header('Location: contact.php');
?>
-----------------------------------------------------------------------------------------------