PHP mailer SMTP - Not working

0

The code I have is the following:

require_once ( 'class.phpmailer.php' );
$Mail = new PHPMailer();

$Mail->IsSMTP(); 
$Mail->Host        = ""; // O QUE COLOCAR AQUI??
$Mail->SMTPDebug   = 0; // 2 to enable SMTP debug information
$Mail->SMTPAuth    = TRUE; 
$Mail->SMTPSecure  = "ssl"; 
$Mail->Port        = 465; 
$Mail->Username    = '[email protected]'; 
$Mail->Password    = 'minhapass'; 
$Mail->Priority    = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From        = '[email protected]';
$Mail->AddAdress    = ('[email protected]'); 
$Mail->WordWrap    = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->isHTML( TRUE );
$Mail->SMTPDebug   = 1;

$Mail->Body  = "corpo";
$Mail->AddAddress("[email protected]"); // To: 
$Mail->Send();

Thank you

    
asked by anonymous 01.02.2016 / 23:23

1 answer

4

It's missing the host that will send the message, I think it's smtp.gmail.com for Gmail:

$Mail->Host = "smtp.gmail.com";

If it does not work, enable debug mode:

$Mail->SMTPDebug   = 1;

Also change the last line:

$Mail->Send();

For this code:

if(!$Mail->Send()) { 
    echo "Mailer Error: " . $Mail->ErrorInfo; 
} else { 
    echo "Enviado com sucesso!"; 
}

Change your question and post the error that is returned, so we'll have more information.

    
02.02.2016 / 00:16