Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I´m trying to test my emails on localhost, and I´m getting this error: SMTP Error: Could not authenticate.
Somebody there know how to send emails on localhost? Can see if I´m doing something wrong? Because I guess everything is correct and I´m not understanding what is happening to have this error.

I did this configuration in php.ini ony my xampp folder:

CSS
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 = myemail@hotmail.com


Im using php mailer class to send the email:

C#
<?php
    define('MAILUSER','myemail@hotmail.com');
    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($destination),utf8_decode($destinationName));

            if($mail->Send()){
                return true;
            }else{
                return false;
            }
        }
    ?>
Posted

1 solution

You must be using mercury, check this out: configureMercuryMail[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900