Ciao, come ha detto @Alhazred, nel caso di un errore questo non viene stampato, prova questo:
Codice PHP:
<?PHP
define("my_email", "");
define("my_password", "");
require_once("class.phpmailer.php");
$error = "";
function sendMail($to, $from, $from_name, $subject, $body){
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = my_email;
$mail->Password = my_password;
$mail->SetFrom($from, $from_name, false);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()){
$error .= $mail->ErrorInfo;
return false;
}
return true;
}
$sendMail = sendMail("to@gmail.com","from@gmail.com","fromName","subject","body");
if($sendMail === true)
echo "Mail inviata.";
else
echo "C'è stato un errore durante l'invio della mail: {$error}.";