我想测试我的电子邮件功能在本地主机phpmailer类。
SMTP error: Could not authenticate.这个错误是因为我没有一个本地主机的电子邮件配置。
我已经在我的Xampp php.ini中做了这个配置,以尝试在本地主机上测试电子邮件:
[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
但是它不起作用,有人知道如何在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;
}
}
?>
我在这里发送电子邮件:
$msg = 'hello';
sendMail('Sent email!',$msg,MAILUSER,SITENAME,$assoc['email'],$assoc['name']);
也许您的SMTP配置需要更新?查看有关Hotmail SMTP设置的文章:
http://www.serversmtp.com/en/smtp-hotmail