[英]Trying to test send emails on localhost -> SMTP Error: Could not authenticate
Im trying to test my emails functions in localhost with phpmailer class. 我试图用phpmailer类在localhost中测试我的电子邮件功能。
But I´m getting this error: SMTP Error: Could not authenticate.. 但我收到此错误: SMTP错误:无法验证。
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: 我已经在Xampp php.ini中进行了此配置,以尝试在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 = myemail@hotmail.com
But its not working, Somebody there knows How to do this work on windows 8 with xampp? 但是它不起作用,那里的人知道如何在Windows 8上使用xampp进行此工作?
<?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($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']);
Maybe your SMTP configuration needs to be updated? 也许您的SMTP配置需要更新? See this article about the Hotmail SMTP settings: 请参阅有关Hotmail SMTP设置的文章:
http://www.serversmtp.com/en/smtp-hotmail http://www.serversmtp.com/en/smtp-hotmail
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.