-1
我想從本地服務器發送郵件,但郵件不會在本地發送。錯誤是:郵件不會從本地服務器發送
SMTP Error: Could not authenticate.
<?php
include_once'mail/class.phpmailer.php';
include_once'mail/class.pop3.php';
include_once'mail/class.smtp.php';
class MailSender{
public static function SendMail($to,$subj,$body,$username){
$mail=new PHPMailer();
$mail->IsSMTP();
//$mail->Host="mail.gmail.com";
$mail->SMTPAuth=true;
$mail->SMTPSecure = 'ssl';
$mail->Host="smtp.gmail.com";
$mail->Port=587;
$mail->Username="[email protected]";
$mail->Password="fdslkfsd";
$mail->SetFrom('[email protected]','Rahul lodhi');
$mail->Subject=$subj;
$mail->MsgHTML($body);
$mail->AltBody="to view the msg";
$address=$to;
$mail->AddAddress($address,$username);
if(!$mail->Send()){
return"Mailer Error :".$mail->ErrorInfo;
}else{
return"message sent";
}
}
}
?>
你有沒有嘗試過的東西或搜索有關錯誤的信息? – javierfdezg
是的,但沒有找到正確的解決方案 –
您是否在PHP中啓用了OpenSSL支持?你也定義了兩次主機。 – javierfdezg