Reputation: 219
Im trying to test my emails functions in localhost with phpmailer class.
But I´m getting this error: SMTP Error: Could not authenticate..
And this error its because I dont have a localhost email configured.
I already did this configuration in my Xampp php.ini to try test emails on localhost:
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = localhost
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
But its not working, Somebody there knows How to do this work on windows 8 with xampp?
<?php
define('MAILUSER','[email protected]');
define('MAILPASS','');
define('MAILPORT','587');
define('MAILHOST','smtp.live.com');
define('SITENAME', 'Site Name');
function sendMail($subject,$message,$sender,$senderName,$destination,$destinationName, $reply = NULL, $replyNome = NULL){
require_once('mail/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->IsHTML(true);
$mail->Host = MAILHOST;
$mail->Port = MAILPORT;
$mail->Username = MAILUSER;
$mail->Password = MAILPASS;
$mail->From = utf8_decode($sender);
$mail->FromName = utf8_decode($senderName);
if($reply != NULL){
$mail->AddReplyTo(utf8_decode($reply),utf8_decode($replyNome));
}
$mail->Subject = utf8_decode($assunto);
$mail->Body = utf8_decode($mensagem);
$mail->AddAddress(utf8_decode($destino),utf8_decode($destinationName));
if($mail->Send()){
return true;
}else{
return false;
}
}
?>
Here I send the email:
$msg = 'hello';
sendMail('Sent email!',$msg,MAILUSER,SITENAME,$assoc['email'],$assoc['name']);
Upvotes: 0
Views: 1319
Reputation: 32748
Maybe your SMTP configuration needs to be updated? See this article about the Hotmail SMTP settings:
http://www.serversmtp.com/en/smtp-hotmail
Upvotes: 1